chickadee » list-utils » section

(section LIST SIZE [[STEP] PADS]) => listprocedure

Returns a list of list, built by taking SIZE elements from LIST every STEP elements. When too few elements remain to complete a section padding is performed.

SIZE is a positive fixnum. STEP is a positive fixnum. Default is SIZE. PADS is a list or #f. Default is '().

When PADS is #f then any incomplete trailing section is dropped. The very odd treatment of PADS = #f can safely be ignored since this is not the default behavior.

(section '(1 2) 3 3 '(3 4 5)) ;=> ((1 2 3))
(section '(1 2 3) 2 1 '(3 4 5)) ;=> ((1 2) (2 3))
(section '(1 2 3) 2 2 '(4 5)) ;=> ((1 2) (3 4))
(section '(1 2 3) 2 2) ;=> ((1 2) (3))