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))

Your annotation:

Enter a new annotation:

Your nick:
The title of your paste:
Your paste (mandatory) :
Which procedure can be used to check whether its argument is a string?
Visually impaired? Let me spell it for you (wav file) download WAV