[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Axiom-developer] How to enumerate a product of lists (or integer sets)

From: Francois Maltey
Subject: [Axiom-developer] How to enumerate a product of lists (or integer sets)
Date: 15 Oct 2007 14:48:41 +0200
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.4


I try to enumerate all the matrices

[[     a,      b, 15-a-b],
 [     c,      d, 15-c-d],
 [15-a-c, 15-b-d, 15-a-d]]   with (a,b,c,d) in 1..9.

in fact (a, d) are members of 2..8, 
    and (b, c) are in 1..9.

It's the first question of an exercice which try to find 
the magic matrix with the same sum in all directions.

With axiom I only find this multi-line command :
L := reduce
      [[matrix [[a,b,15-a-b],[c,d,15-c-d],[15-a-c,15-b-d,15-a-d]] 
        for a in 1..9] for b in 1..9]) for c in 1..9]) for d in 1..9]) ;

a train of for creates only one zip-list.
[[i,j]for i in 1..5 for j in 1000..2000] create the short list

The syntax of mupad/maple is shorter with the operator $

L :=  [matrix [[a,b,15-a-b],[c,d,15-c-d],[15-a-c,15-b-d,15-a-d]] 
          $for a in 1..9 $for b in 1..9 $for c in 1..9 $for d in 1..9] :

Maple needs quote ":" in order to restain the evaluation.

L :=  ['''matrix [[a,b,15-a-b],[c,d,15-c-d],[15-a-c,15-b-d,15-a-d]] 
          $for a in 1..9' $for b in 1..9' $for c in 1..9' $for d in 1..9] :

Is there an other way with axiom ?


reply via email to

[Prev in Thread] Current Thread [Next in Thread]