|  |  | Packers

## Packers

Packers are the complement of enumerators and are the imperative version of `fold`. The default packer returns a list of all accumulated values:

    (packing (for ((e '(1 2 3 4 5)))
               (when (odd? e) (pack e))))  ==> (1 3 5)

They can also be used for summing values etc:

    (packing-in (x|<int>)
      (for ((e '(1 2 3 4 5)))
        (when (odd? e) (pack-in x e)))
      (packed x))  ==> 9

`<packer>` | `(<any>)` | `C`
`packer-add` | `(p|<packer> x => <packer>)` | `G`
| returns a copy packer `p` augmented with element `x`. |
`packer-res` | `(p|<packer> => <any>)` | `G`
| returns result of packings over `p`. |
`packer` | `(init add|<fun> res|<fun>)` | `G`
| returns a simple packer that starts its value out with `init`, is augmented with `add`, and whose final value is computed with `res`. |
`packer-fab` | `(t|<type> => <packer>)` | `G`
| returns a new type `t` specific packer. |
`packer-fab` | `(t|(t< <seq>) => <packer>)` | `M`
| == `(packer '() pair (op as t (rev! _)))` |
`packer-fab` | `(t|(t= <int>) => <packer>)` | `M`
| == `(packer 0 + (op _))` |
`PACKING-WITH` | `(PACKING-WITH ((,var ,pack) ...) ,@body)` | `S`
| mechanism for packing objects using given packer into `,var`. |
`PACKING-IN` | `(PACKING-IN (,name '|' ,type ...) ,@body)` | `S`
| == `(PACKING-WITH (,name (packer-fab ,type)) ,@body)`. |
| `(PACKING-IN (,name) ,@body)` | `S`
| == `(PACKING-IN (,name '|' <lst>) ,@body)`. |
`PACKING` | `(PACKING ,@body)` | `S`
| == `(PACKING-IN (packer-) ,@body (packed packer-))`. |
`PACK-IN` | `(PACK-IN ,pack ,x)` | `S`
| folds `,x` into packer in `,pack`. |
`PACK` | `(PACK ,x)` | `S`
| == `(PACK packer- ,name)`. |
`PACKED` | `(PACKED ,name)` | `S`
| == `(packer-res ,name)`. |

|  |  | Packers