|  |  | Collections

# Collections

Collections are aggregate data structures mapping keys to values. Collections can be almost entirely defined in terms of an enumeration class.

`<col>` | `(<any>)` | `C`
`<col.>` | `(<col>)` | `C`
| immutable collections. |
`fab` | `(t|(t< <col>) n|<int> => <col>)` | `G`
| returns a new instance of collection type `t` of len `n`. |
`col` | `(t|(t< <col>) key-vals|... => <col>)` | `G`
| returns new collection of type `t` with initial key values `key-vals`. |
`fabs` | `(t|(t< <col>) elts|... => <col>)` | `G`
| returns new collection of type `t` with initial values `elts` and keys `(below (len elts))`. |
`len` | `(x|<col> => <int>)` | `G`
| returns number of collection elements. |
`col-res-type` | `(x|<col> => <type>)` | `G`
| appropriate instantiable type for creating collection results, where the default is `(class-of x)`. |
`nul?` | `(x|<col> => <log>)` | `G`
| == `(= (len x) 0)` |
`nul` | `(x|(t< <col>) => <col>)` | `G`
| returns collection specific unique empty value. |
`key-test` | `(x|<col> => test|<fun>)` | `G`
| returns collection's key equality function. |
| `(x|<col> => (t= ==))` | `M`
| default key-test is identity function. |
`key-type` | `(x|<col> => <type>)` | `G`
| returns collection `x`'s key type. |
`elt-type` | `(x|<col> => <type>)` | `G`
| returns collection `x`'s element type. |
`elt` | `(x|<col> k|<any> => <any>)` | `G`
| returns collection `x`'s element associated with key `k`. |
`'[' ... ']'` | `'[' ,x ,k ']'` | `S`
| == `(elt ,x ,k)` |
`elt-or` | `(x|<col> k d => <any>)` | `G`
| returns collection `x`'s element associated with key `k` or default `d` if it doesn't exist. |
`mem?` | `(x|<col> y|<any> => <log>)` | `G`
| returns true iff `y` is an element of `x`. |
`add` | `(x|<col> y|<any> => <col>)` | `G`
| returns collection with `y` added to `x`. |
`elts` | `(x|<col> keys|<seq> => <col>)` | `G`
| subset of elements of `x` corresponding to keys `keys`. |
`dup` | `(x|<col> => <col>)` | `G`
| returns shallow copy of `x`. |
`keys` | `(x|<col> => <seq>)` | `G`
| returns `x`'s keys. |
`items` | `(x|<col> => <seq>)` | `G`
| returns a sequence of `x`'s key/val tuples. |
`del` | `(x|<col> key|<any> => <col>)` | `G`
| returns copy of `x`'s without element corresponding to `key`. |
`zap` | `(x|<col> => <col>)` | `G`
| returns empty copy of `x`. |
`fill` | `(x|<col> y|<any> => <col>)` | `G`
| returns copy of `x` with all values being `y`. |
`any?` | `(f|<fun> x|<col> => <log>)` | `G`
| returns true iff any of `x`'s element satisfies given predicate `f`. |
`find` | `(f|<fun> x|<col> => <any>)` | `G`
| returns key associated with first of `x`'s values to satisfy predicate `f`. |
`find-or` | `(f|<fun> x|<col> default => <any>)` | `G`
| returns key associated with first of `x`'s values to satisfy predicate `f` or `default` if not found. |
`all?` | `(f|<fun> x|<col> => <log>)` | `G`
| returns true iff all of `x`'s elements satisfies given predicate `f`. |
`fold` | `(f|<fun> init|<any> x|<col> => <col>)` | `G`
| == `(f (f ... (f init (elt x 0)) (elt x (- n 2))) (elt x (- n 1)))` |
`fold+` | `(f|<fun> x|<col> => <any>)` | `G`
| == `(f (f ... (f (elt x 0) (elt x 1)) (elt x (- n 2))) (elt x (- n 1)))` |
`do` | `(f|<fun> x|<col>)` | `G`
| iterates function `f` over values of `x` for side-effect. |
`map` | `(f|<fun> x|<col> => <col>)` | `G`
| iterates function `f` over values of given collections and collects the results. |

- Mutable Collections
- Enumerators
- Packers
- Maps
- Sequences
- Lazy Series'

|  |  | Collections