list->slices

pull/2/head
Matthew Butterick 10 years ago
parent a2391ab583
commit 05516c51da

@ -7,6 +7,16 @@
(list? procedure? . -> . list?)
(dropf-right (dropf items test-proc) test-proc))
;; convert a list into a list of slices that are len long (last one might be shorter)
(define+provide/contract (list->slices xs len)
(list? integer? . -> . (listof list?))
(cond
[(equal? xs null) null]
[(len . > . (length xs)) (list xs)]
[else (cons (take xs len) (list->slices (drop xs len) len))]))
;; split list into list of sublists using test-proc
(define+provide/contract (splitf-at* xs split-test)

Loading…
Cancel
Save