The commands pack(A, n) and pack(n, A) produce identical results.
i1 : pack(a..l, 3) o1 = {{a, b, c}, {d, e, f}, {g, h, i}, {j, k, l}} o1 : List |
i2 : pack(3, a..l) o2 = {{a, b, c}, {d, e, f}, {g, h, i}, {j, k, l}} o2 : List |
If n doesn't divide the length of A, the last list will have fewer than n elements.
i3 : pack(a..m, 3) o3 = {{a, b, c}, {d, e, f}, {g, h, i}, {j, k, l}, {m}} o3 : List |
pack and mingle can be used together to take a transpose of lists
i4 : pack(2, mingle(a..m, 0..12)) o4 = {{a, 0}, {b, 1}, {c, 2}, {d, 3}, {e, 4}, {f, 5}, {g, 6}, {h, 7}, {i, 8}, ------------------------------------------------------------------------ {j, 9}, {k, 10}, {l, 11}, {m, 12}} o4 : List |
The object pack is a compiled function.