#lang scheme (require scheme/string) (define (chunky li sz [str ""]) (let ([graft (lambda (s l) (string-append s (string-join l " ") "\n"))]) (if [<= (length li) sz] (graft str li) (let-values ([(x y) (split-at li sz)]) (chunky y sz (graft str x)))))) (display (chunky '("a" "bb" "c" "d" "e" "f" "g" "h") 3))
+% mzscheme chunky.ss a bb c d e f g h +%
In reply to Re: Rosetta code: Split an array into chunks
by Arunbear
in thread Rosetta code: Split an array into chunks
by eyepopslikeamosquito
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |