🧭Functional Programming
Also known as FP, Functional Style
Code that hands back new values from small functions. Nothing changes in place.
Think of it like
Think of it like a juice press. Put in apples, get out juice, and the press never changes.
Example
Lucy turns a list of prices into prices with tax using map. The old list stays as it was, and a new list comes back.
Why it matters
Code that changes nothing outside itself is easier to test. It is also safer when many things run at once.
Definition
Common mistake
Key takeaways
- 1Small functions. Inputs in, outputs out.
- 2No changes in place. Make a new copy instead.
- 3Functions are values. Pass them around freely.