[GAP Forum] Iteration Over Lists of Lists
Alexander Konovalov
alexander.konovalov at gmail.com
Thu Jan 16 22:01:26 GMT 2014
On 16 Jan 2014, at 20:03, "Wolstenholme, Robert" <robert.wolstenholme08 at imperial.ac.uk> wrote:
> Is there a way in GAP to 'quickly' iterate of lists of lists i.e. like the Python itertools.product() function?
>
Yes, see `21.20 Operations for Lists' from the GAP Reference Manual. You may enter `?Operations for Lists' in GAP or see it online at
http://www.gap-system.org/Manuals/doc/ref/chap21.html#X7DF510F7848CBBFD
A random example just to expose the syntax and some functions:
gap> l:=List([1..10],i -> [1..i]);
[ [ 1 ], [ 1, 2 ], [ 1 .. 3 ], [ 1 .. 4 ], [ 1 .. 5 ], [ 1 .. 6 ],
[ 1 .. 7 ], [ 1 .. 8 ], [ 1 .. 9 ], [ 1 .. 10 ] ]
gap> Sum( List( l, x -> Product( List( x, Fibonacci ) ) ) );
124819000
HTH,
Alexander
More information about the Forum
mailing list