Dear Gap Forum,
Drew Krause asked:
Hi, maybe I've overlooked this function in the documentation somewhere.
Can someone tell me the best way to build an array of sublists from a
given flat list, e.g.from "[1,2,3,4]" to "[[1,2],[3,4]]" ?
There is no such function in the library. Let w be the length of each
sublist (the dimensions are not always unique, use `RootInt' for a square).
Then the following construction seems to be the shortest way to construct
the array:
gap> l:=[9..14];;w:=2;; # for example gap> sub:=[1..w];;List([1..Length(l)/w],i->l{(i-1)*w+sub}); [ [ 9, 10 ], [ 11, 12 ], [ 13, 14 ] ]
Best regards,
Alexander Hulpke