Example 1 — Official Add, Then Multiply
Add 10, then multiply by 10 — the math sample from the Ramda docs.
const addThenTimes10 = R.o(R.multiply(10), R.add(10));
console.log(addThenTimes10(-4)); // 60 How It Works
- Compose.
R.ostores both functions and returnsaddThenTimes10; nothing runs yet. - Right first.
R.add(10)turns-4into6. - Left second.
R.multiply(10)turns6into60. - Read it backwards. The function written last runs first.
