[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Axiom-developer] How to enumerate a product of lists (or integer se
From: |
Francois Maltey |
Subject: |
Re: [Axiom-developer] How to enumerate a product of lists (or integer sets) |
Date: |
15 Oct 2007 16:53:32 +0200 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.4 |
Many thanks dear Martin !
> L := concat [concat [concat [[[a,b,c,d] _
> for a in 1..9] _
> for b in 1..9] _
> for c in 1..9] _
> for d in 1..9]
>
> and then loop over them:
>
> [eval(matrix [[a,b,15-a-b],[c,d,15-c-d],[15-a-c,15-b-d,15-a-d]], [a,b,c,d],
> l) for l in L]
I ignore this way. It's better than this too long command line map :
map (l +-> matrix [[l.1,l.2,15-l.1-l.2],[...],[...]], L)
In mupad there is the short-cut
map ([a,b,c,d] -> matrix [[a,b,15-a-b],[c,d,15-c-d],[15-a-c,15-b-d,15-a-d]], L)
Is there no way to find it in axiom ?
The eval seems quite different :
the map doesn't create any symbolic matrix
but the eval create symbolic matrices. Am I right ?
> > a train of for creates only one zip-list.
> Yes, and that's something very useful! For example
> [f(l, i) for l in L for i in 1..]
> is in my opinion much better to read then [f(L.i, i) for i in 1..#L]
> and [f(l) for l in L for i in 1..4] for the four first.
It's right ! train of for are useful.
But I take note that exercices for my students use a lot
of cartesian products with $...$... and very view train of for as above.
I don't suggest a where operator [f(i,j) for i in 1..10 where j in L]
for cartesian product ;-)
Francois