Higher-Order Functions
- Functions taking functions. Higher-order functions abstract patterns: retry(3)(fetchUser) wraps behaviour around behaviour.
- Currying. Curried parameter lists specialise functions stepwise: configuration first, data later.
- Function composition. andThen and compose chain functions: pipelines built from named pieces.
Pure Functions and Immutability
- Purity. A pure function reads only inputs and changes nothing: same arguments, same answer, testable in isolation.
- Referential transparency. Referential transparency lets you substitute a call with its value: the property equational reasoning needs.
- Effects at the edges. Idiomatic Scala keeps side effects at the boundary: a pure core, I/O in a thin shell.
Function Composition
- Small functions compose. Design as composition: validate andThen enrich andThen price: each step named, tested, reused.
- for-comprehensions. A for-comprehension chains map and flatMap readably: Options, Eithers and Futures sequenced alike.
- Pipelines over loops. Scala replaces loop bookkeeping with pipelines: intent stated, indexes deleted.
Before and after this level
- Before: Level 4: Algebraic Data Types: Enums and Case Classes, Pattern Matching, Modelling Valid States.
- Next: Level 6: Type System: Generics, Variance, Type Bounds and Advanced Types.
In the app each of these ideas is taught and then asked back, and the level ends with a checkpoint and flashcards. See Checkpoints and flashcards.
Frequently asked questions
What does Scala Level 5: Functional Programming cover?
Higher-Order Functions, Pure Functions and Immutability, Function Composition: 3 lessons and 9 ideas.
What should I know before this level?
The level before it, Level 4: Algebraic Data Types, which covers Enums and Case Classes, Pattern Matching, Modelling Valid States.