Add a chunk procedure
Just a variant of chunk! which doesn't modify the provided list.
This commit is contained in:
parent
af0a06d147
commit
0796cb3bd3
1 changed files with 11 additions and 0 deletions
|
|
@ -31,6 +31,7 @@
|
||||||
par-map&
|
par-map&
|
||||||
letpar&
|
letpar&
|
||||||
|
|
||||||
|
chunk
|
||||||
chunk!))
|
chunk!))
|
||||||
|
|
||||||
(define (call-with-time-logging action thunk)
|
(define (call-with-time-logging action thunk)
|
||||||
|
|
@ -155,6 +156,16 @@
|
||||||
|
|
||||||
(define par-map& (par-mapper' map cons))
|
(define par-map& (par-mapper' map cons))
|
||||||
|
|
||||||
|
(define (chunk lst max-length)
|
||||||
|
(if (> (length lst)
|
||||||
|
max-length)
|
||||||
|
(call-with-values (lambda ()
|
||||||
|
(split-at lst max-length))
|
||||||
|
(lambda (first-lst rest)
|
||||||
|
(cons first-lst
|
||||||
|
(chunk rest max-length))))
|
||||||
|
(list lst)))
|
||||||
|
|
||||||
(define (chunk! lst max-length)
|
(define (chunk! lst max-length)
|
||||||
(if (> (length lst)
|
(if (> (length lst)
|
||||||
max-length)
|
max-length)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue