Ga naar de hoofdinhoud

Choose map, filter, or reduce by the contract

Select map, filter, or reduce based on the shape change a collection operation performs.

functional-programming5 min read

The move: choose the operator by what happens to the collection. Most loops become hard to review when they mix three jobs: deciding what belongs, changing each item, and building a final summary. Functional collection operators make those jobs visible. Map transforms Use map when every item becomes a corresponding item. Order count stays the same; item shape changes. Example: order rows become invoice rows. Filter selects Use filter when the output is a subset. Item shape stays the same; count may shrink. Example: all orders become only billable orders. Reduce accumulates Use reduce when the collection becomes one value…

Read the full lesson

Sign up free: one personalized lesson every day, matched to your role and goals.

← Back to library

Neem contact op