Scheme 48 Manual | Contents | In Chapter: Libraries
Previous: Libraries | Next: Pretty-printing

## General utilities

These are in the `big-util` structure.

- `(atom? value) -> boolean`

`(atom? x)` is the same as `(not (pair? x))`.

- `(null-list? list) -> boolean`

Returns true for the empty list, false for a pair, and signals an error otherwise.

- `(neq? value value) -> boolean`

`(neq? x y)` is the same as `(not (eq? x y))`.

- `(n= number number) -> boolean`

`(n= x y)` is the same as `(not (= x y))`.

- `(identity value) -> value`
- `(no-op value) -> value`

These both just return their argument. `No-op` is guaranteed not to be compiled in-line, `identity` may be.

- `(memq? value list) -> boolean`

Returns true if value is in list, false otherwise.

- `(any? predicate list) -> boolean`

Returns true if predicate is true for any element of list.

- `(every? predicate list) -> boolean`

Returns true if predicate is true for every element of list.

- `(any predicate list) -> value`
- `(first predicate list) -> value`

`Any` returns some element of list for which predicate is true, or false if there are none. `First` does the same except that it returns the first element for which predicate is true.

- `(filter predicate list) -> list`
- `(filter! predicate list) -> list`

Returns a list containing all of the elements of list for which predicate is true. The order of the elements is preserved. `Filter!` may reuse the storage of list.

- `(filter-map procedure list) -> list`

The same as `filter` except the returned list contains the results of applying procedure instead of elements of list. `(filter-map p l)` is the same as `(filter identity (map p l))`.

- `(partition-list predicate list) -> list list`
- `(partition-list! predicate list) -> list list`

The first return value contains those elements list for which predicate is true, the second contains the remaining elements. The order of the elements is preserved. `Partition-list!` may reuse the storage of the list.

- `(remove-duplicates list) -> list`

Returns its argument with all duplicate elements removed. The first instance of each element is preserved.

- `(delq value list) -> list`
- `(delq! value list) -> list`
- `(delete predicate list) -> list`

All three of these return list with some elements removed. `Delq` removes all elements `eq?` to value. `Delq!` does the same and may modify the list argument. `Delete` removes all elements for which predicate is true. Both `delq` and `delete` may reuse some of the storage in the list argument, but won't modify it.

- `(reverse! list) -> list`

Destructively reverses list.

- `(concatenate-symbol value ...) -> symbol`

Returns the symbol whose name is produced by concatenating the `display`ed representations of value ....

>     (concatenate-symbol 'abc "-" 4) ==> 'abc-4

Previous: Libraries | Next: Pretty-printing