Write a function that given a list, will group the items in sub lists of n items.
For example, if we defined a function GroupItems, that takes two arguments, a list 'lst' and a grouping number 'n', this snippette:
( (lambda ( / lst )
(setq lst '(1 2 3 4 5 6 7 8 9 10))
(foreach n lst
(princ
(strcat
"\nGrouped "
(itoa n)
" at a time: "
)
)
(princ (GroupItems lst n))
)
(princ)
)
)
Might produce this:
Grouped 1 at a time: ((1) (2) (3) (4) (5) (6) (7) (8) (9) (10))
Grouped 2 at a time: ((1 2) (3 4) (5 6) (7 8) (9 10))
Grouped 3 at a time: ((1 2 3) (4 5 6) (7 8 9) (10))
Grouped 4 at a time: ((1 2 3 4) (5 6 7 8) (9 10))
Grouped 5 at a time: ((1 2 3 4 5) (6 7 8 9 10))
Grouped 6 at a time: ((1 2 3 4 5 6) (7 8 9 10))
Grouped 7 at a time: ((1 2 3 4 5 6 7) (8 9 10))
Grouped 8 at a time: ((1 2 3 4 5 6 7 8) (9 10))
Grouped 9 at a time: ((1 2 3 4 5 6 7 8 9) (10))
Grouped 10 at a time: ((1 2 3 4 5 6 7 8 9 10))
Note how it might deal with lists that do not divide evenly by the grouping number 'n'.
Enjoy.