Back to library

💻Functional Programming Fundamentals

Stop treating FP like an ideology and start using its cheap wins — pure functions, immutability, map/filter/reduce, and composition — until you can rewrite a small imperative program in clean functional style.

Foundations14 drops~2-week path · 5–8 min/daytechnology

Phase 1The Mental Shift: From Steps to Values

See pure functions, immutability, and referential transparency.

4 drops
  1. A pure function is just inputs to outputs — nothing else

    6 min

    A pure function depends on its arguments alone and changes nothing outside itself.

  2. Don't change the value — return a new one

    6 min

    Immutability replaces mutation with new-value-each-time, eliminating a whole class of bugs.

  3. If you can swap the call for its result, you have referential transparency

    6 min

    Referential transparency means an expression can be replaced with its value without changing program behavior.

  4. Push side effects to the edges of your program

    7 min

    Side effects can't be eliminated — but they can be cornered into a thin shell around a pure core.

Phase 2Replacing Loops With Map, Filter, Reduce

Refactor for-loops into map, filter, and reduce.

5 drops
  1. map is a for-loop that returns a new array

    5 min

    map applies a function to every element and produces a new array of the same length.

  2. filter keeps the elements that pass the test

    5 min

    filter takes a predicate and returns only the elements where it returns true.

  3. reduce collapses an array down to a single value

    7 min

    reduce walks through an array carrying an accumulator, returning the final accumulator at the end.

  4. Chain map, filter, and reduce to read like a sentence

    7 min

    Chained transformations replace nested loops and intermediate variables with a single readable pipeline.

  5. Recursion is FP's loop — and it's friendlier than you remember

    7 min

    Recursion expresses repetition in terms of the function calling itself with a smaller problem.

Phase 3Higher-Order Functions and Composition

Compose higher-order functions and curry for reuse.

4 drops
  1. A teammate hands you a function. Now what?

    6 min

    A teammate hands you a function. Now what?

  2. Two pure functions glued back-to-back is still a function

    7 min

    Two pure functions glued back-to-back is still a function

  3. One function, many arities, no headaches

    7 min

    One function, many arities, no headaches

  4. The function remembered what was around when it was born

    7 min

    The function remembered what was around when it was born

Phase 4Capstone: Rewrite It Functionally

Rewrite an imperative program in a pure functional style.

1 drop
  1. Rewrite a small imperative program in pure functional style

    25 min

    Rewrite a small imperative program in pure functional style

Frequently asked questions

What makes a function 'pure' in functional programming?
This is covered in the “Functional Programming Fundamentals” learning path. Start with daily 5-minute micro-lessons that build from fundamentals to hands-on application.
Why does immutability matter if I never mutate anyway?
This is covered in the “Functional Programming Fundamentals” learning path. Start with daily 5-minute micro-lessons that build from fundamentals to hands-on application.
When should I reach for reduce instead of a for loop?
This is covered in the “Functional Programming Fundamentals” learning path. Start with daily 5-minute micro-lessons that build from fundamentals to hands-on application.
What's the difference between map and forEach?
This is covered in the “Functional Programming Fundamentals” learning path. Start with daily 5-minute micro-lessons that build from fundamentals to hands-on application.
Do I need a special language to write functional code?
This is covered in the “Functional Programming Fundamentals” learning path. Start with daily 5-minute micro-lessons that build from fundamentals to hands-on application.