2.3 Lists
| (require toolbox/list) | package: toolbox-lib |
procedure
(take-at-most lst n) → list?
lst : list? n : exact-nonnegative-integer?
Like take, except if lst has fewer than n elements, take-at-most returns lst instead of raising an exception.
Examples:
> (take-at-most '(1 2 3 4 5) 3) '(1 2 3)
> (take-at-most '(1 2) 3) '(1 2)
procedure
(split-at-most lst n) →
list? list? lst : list? n : exact-nonnegative-integer?
Like split-at, except if lst has fewer than n elements, split-at-most returns (values lst '()) instead of raising an exception.
Examples:
> (split-at-most '(1 2 3 4 5) 3)
'(1 2 3)
'(4 5)
> (split-at-most '(1 2) 3)
'(1 2)
'()
procedure
(maybe->list v) → list?
v : any/c
syntax
(when/list test-expr body ...+)
syntax
(unless/list test-expr body ...+)
syntax
(when/list* test-expr body ...+)
Equivalent to (if test-expr (let () body ...) '()), except that the last body form must evaluate to a list, or an exn:fail:contract exception is raised.
syntax
(unless/list* test-expr body ...+)
Equivalent to (if test-expr '() (let () body ...)), except that the last body form must evaluate to a list, or an exn:fail:contract exception is raised.