<i>GOO</i> Manual -- Mutable Collections

|  |  | Mutable Collections

## Mutable Collections

Mutation is seen as a necessary evil and is supported but segregated in hopes of trying to isolate and optimize the nondestructive cases. Mutation includes the notion of modifying values and adding/removing keys. The hope is that functional (nondestructive) programs will be both more succinct, understandable, and efficient than equivalent destructive programs. Only core collection operators are given destructive versions. All others can be built out of nondestructive operators followed by `into` 1.

`<col!>` | `(<any>)` | `C`
`elt-setter` | `(v|<any> x|<col!> k|<any>)` | `G`
| sets collection `x`'s element associated with key `k` to `v`. |
`into` | `(x|<col!> y|<col> => <col!>)` | `G`
| replaces elements of `x` with elements of `y`. |
`elt!` | `(x|<col!> y|<any default|<fun> => <any>)` | `G`
| == `(or (elt-or c k #f) (set (elt c k) (default)))` but uses unique default key for `elt-or` instead of false. |
`fill!` | `(x|<col!> y|<any> => <col!>)` | `G`
| fills `x` with `y`'s. |
`add!` | `(x|<seq!> y|<any => <seq!>)` | `G`
| adds `y` to `x`. |
`del!` | `(x|<col!> key|<any> => <col!>)` | `G`
| removes `key` from `x`. |
`zap!` | `(x|<col!> => <col!>)` | `G`
| removes all of `x`'s elements. |

|  |  | Mutable Collections