# Composition

> pipe, flow and partial for wiring functions left to right.

Source: https://docs.pyrula.io/primitives/composition/

```python
from pyrula import pipe, flow, partial

# pipe threads a value through functions
pipe("  Hello World  ", str.strip, str.lower, lambda s: s.replace(" ", "-"))   # "hello-world"

# flow builds a reusable function from the same steps
slugify = flow(str.strip, str.lower, lambda s: s.replace(" ", "-"))
slugify("  Hello World  ")   # "hello-world"

# partial fixes leading arguments; the result works in pipe and flow
def clamp(lo, hi, x):
    return max(lo, min(hi, x))

partial(clamp, 0, 255)(300)   # 255
```
