Revision: 30902
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at August 25, 2010 03:44 by jcubic
Initial Code
(define (skip list n)
(cond ((null? list) '())
((<= n 0) list)
(else
(skip (cdr list) (- n 1)))))
(define (splice list n m)
(let loop ((stop (- m n)) (list (skip list n)))
(if (or (eq? stop 0) (null? list))
'()
(cons (car list) (loop (- stop 1) (cdr list))))))
(define (group-for list count)
(let ((step (/ (length list) count)))
(let loop ((i 0))
(if (eq? i count)
'()
(cons (splice list (* i count) (* (+ i 1) count))
(loop (+ i 1)))))))
Initial URL
Initial Description
Function group-for which return list of list of length n. (group-for '(1 2 3 4 5 6 7 8 9) 3) => ((1 2 3) (4 5 6) (7 8 9))
Initial Title
Function split list to lists of length n.
Initial Tags
Initial Language
Scheme