On this page:
2.1 Booleans
->boolean
2.2 Boxes
box-cas-update!
box-cas-update!*
box-add1!
box-sub1!
2.3 Lists
take-at-most
split-at-most
maybe->list
when/  list
unless/  list
when/  list*
unless/  list*
2.4 Strings
when/  string
unless/  string
8.18.0.15

2 Data Structures🔗

2.1 Booleans🔗

 (require toolbox/boolean) package: toolbox-lib

procedure

(->boolean v)  boolean?

  v : any/c
Returns #f if v is #f, otherwise returns #t.

2.2 Boxes🔗

 (require toolbox/box) package: toolbox-lib

procedure

(box-cas-update! box proc)  any/c

  box : (and/c box? (not/c immutable?) (not/c impersonator?))
  proc : (-> any/c any/c)
Atomically updates the contents of box by applying proc to the old value to produce a new value. The proc procedure will be applied more than once if the box is concurrently modified between reading the old value and writing the new one, so proc should generally be inexpensive. The result of the call to box-cas-update! is the value written to box.

Examples:
> (define b (box "hello"))
> (box-cas-update! b string-upcase)

"HELLO"

> (unbox b)

"HELLO"

procedure

(box-cas-update!* box proc)  any/c

  box : (and/c box? (not/c immutable?) (not/c impersonator?))
  proc : (-> any/c (values any/c any/c))
Like box-cas-update!, but proc should return two values: the first value is returned, and the second value is written to box.

Examples:
> (define b (box "old"))
> (box-cas-update!* b (λ (old) (values old "new")))

"old"

> (unbox b)

"new"

procedure

(box-add1! box)  number?

  box : (and/c box? (not/c immutable?) (not/c impersonator?))
Equivalent to (box-cas-update! box add1).

procedure

(box-sub1! box)  number?

  box : (and/c box? (not/c immutable?) (not/c impersonator?))
Equivalent to (box-cas-update! box sub1).

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
If v is #f, returns '(), otherwise returns (list v).

syntax

(when/list test-expr body ...+)

Equivalent to (if test-expr (list (let () body ...)) '()).

syntax

(unless/list test-expr body ...+)

Equivalent to (if test-expr '() (list (let () 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.

2.4 Strings🔗

 (require toolbox/string) package: toolbox-lib

syntax

(when/string test-expr body ...+)

Equivalent to (if test-expr (let () body ...) ""), except that the last body form must evaluate to a string, or an exn:fail:contract exception is raised.

syntax

(unless/string test-expr body ...+)

Equivalent to (if test-expr "" (let () body ...)), except that the last body form must evaluate to a string, or an exn:fail:contract exception is raised.