R/MRatCalcpowered by RiX

RiX walkthrough 5 a

Define and call

Define, call, and pass a simple function.

Define a reusable calculation

A function takes inputs called parameters and returns the value of its body. Uppercase names can name callables. Add(3, 4) passes two arguments and returns 7.

Runnable RiX

The same function also works with exact fractions.

Runnable RiX

The result is 1/2. Each level-two topic starts fresh, so this cell includes its own definition. Change either argument and rerun.

Use a short anonymous function

(x) -> x * 2 describes the same rule without naming it. A map pipe applies the rule once to each array item.

Runnable RiX

The result is [2, 4, 6]. See Pipes for that traversal. Scope and imports explains how nested functions see surrounding names; Multifunctions and Partial application are later options.