R/MRatCalcpowered by RiX

RiX walkthrough 5 e

Partial application

Placeholders and arity-capped callables.

Leave an argument open

Partial functions leave a callable shape behind. Operator aliases and numbered placeholders make small callbacks readable, especially inside collection pipelines.

Runnable RiX

_1 stands for the argument supplied later; the result is 18. Compare this with the ordinary Double(x) -> x * 2 in Define and call. Use the version that makes the calculation easier to read.

Use a partial as a callback

Pipes can pass a value, locator and source. A partial that needs only its first argument can cap its arity so the extra context does not change its meaning; see Pipes for the basic callback form. Keep the first callback simple before using placeholders in a pipeline.

Use a second input with Double and check that the placeholder receives the call argument each time.

Continue with Rule dispatcher if your program needs several input families rather than one open argument.