[frames] | no frames]

# Module squish

source code

`squish [BINARY_FUNCTION ...]`

Each input sequence is reduced to a single value, using `BINARY_FUNCTION` to combine the values. `BINARY_FUNCTION` is a binary function that can be used for reduction, e.g. `+`, `*`, `max`, `min`, but not `-` or `/`.

Example: If one of the inputs is the list ```[1, 2, 3, 4]```, then:

```   squish +
```

will generate `10` (= `1 + 2 + 3 + 4`).

The result is exactly equivalent to what would be produced by using the Python function `map`, e.g.:

```   map 'list: squish(lambda a, b: a + b, list)'
```

If input sequences contain nested sequences, then multiple `BINARY_FUNCTION`s can be provided, to do multiple reductions at once. For example, if one input sequence is ```[[10, 20, 30], [1, 100, 1000], [111, 222, 333]]``` then:

```   squish + max min
```

will produce `[122, 222, 30]`. `122` is ```10 + 1 + 111```, `222` is `max(20, 100, 222)`, and `30` is `min(30, 1000, 333)`.

If no `BINARY_FUNCTION` is provided, then `+` is assumed.

Functions

 squish(*squish_ops) Each input sequence is reduced to a single value. source code
 Function Details

### squish(*squish_ops)

source code

Each input sequence is reduced to a single value. Elements of the input sequence are combined using a `squish_op`, a binary function that can be used for reduction, i.e. a binary associative function such as addition, but not subtraction, (because x + y = y + x, but x - y != y - x). If input sequences contain nested sequences, then multiple `squish_op`s can be provided, to do multiple reductions at once. The squish_op can be a function-valued expression, a string function expression (e.g. `'x, y: x + y'`), or a string describing a binary associative operator, specifically one of: ```+, *, ^, &, |, and, or```.

 Generated by Epydoc 3.0.1 on Sun Oct 3 15:23:48 2010 http://epydoc.sourceforge.net