next | previous | forward | backward | up | top | index | toc | home
Macaulay2 > The Macaulay2 language > lists and sequences > pack

pack -- pack elements of a list into shorter ones

Description

pack(n,v) -- packs the elements of the list or sequence v into a table n at a time.

It produces, from a list v, a list of lists formed by packing the elements of v into lists n at a time. The last of the lists produced may have fewer than n elements.

i1 : pack(3,{a,b,c,d,e,f,g,h,i,j,k})

o1 = {{a, b, c}, {d, e, f}, {g, h, i}, {j, k}}

o1 : List

Ways to use pack :