Welcome to the CHICKEN Scheme pasting service
chunk/slice_before added by wasamasa on Tue Feb 9 18:30:22 2016
(define (chunk lis pred) (let loop ((lis lis) (acc '()) (chunk '())) (if (not (null? lis)) (let ((item (car lis))) (if (pred item) (loop (cdr lis) acc (append chunk (list item))) (if (null? chunk) (loop (cdr lis) acc (list item)) (loop lis (append acc (list chunk)) '())))) (append acc (list chunk))))) (chunk '(1 0 0 2 3 4 0 0) zero?) ;=> ((1 0 0) (2) (3) (4 0 0))