5. Concepts
● Declarative vs. Imperative
● Pure Functions
● Higher Order Functions (+Lambdas)
● Immutability
● Recursion
● Laziness
● map/filter/reduce/zip/flatMap
● Currying
6. Declarative vs. Imperative
● Defining WHAT to do vs. HOW to do it
● Expressive
● Improve / Optimize underlying algorithms
● Eliminate Side-effects as much as possible
8. Concepts
● Declarative vs. Imperative
● Pure Functions
● Higher Order Functions (+Lambdas)
● Immutability
● Recursion
● Laziness
● map/filter/reduce/zip/flatMap
● Currying
9. Pure Functions
● No side-effects
● Referential Transparency (caching, ...)
● Thread-safe
● Compiler-Optimizations
● ...
10. Concepts
● Declarative vs. Imperative
● Pure Functions
● Higher Order Functions (+Lambdas)
● Immutability
● Recursion
● Laziness
● map/filter/reduce/zip/flatMap
● Currying
11. Higher Order Functions
● Critical concept in FP
● Functions can take functions as arguments
● Functions can return functions
● Enables functional composition
14. Concepts
● Declarative vs. Imperative
● Pure Functions
● Higher Order Functions (+Lambdas)
● Immutability
● Recursion
● Laziness
● map/filter/reduce/zip/flatMap
● Currying
15. Immutability
● Persistent Data Structures
● Every time a data structure would be mutated, a new one
is returned instead
● Simplifies state management and mutation tracking
● Enables optimizations
● Works well with pure functions
● Memory overhead is mitigated by sharing (Tries)
16. Concepts
● Declarative vs. Imperative
● Pure Functions
● Higher Order Functions (+Lambdas)
● Immutability
● Recursion
● Laziness
● map/filter/reduce/zip/flatMap
● Currying
17. Recursion
● Divide and Conquer
● Can provide elegant solutions for complex problems
● Not as complicated to do, if one knows how ;)
19. Concepts
● Declarative vs. Imperative
● Pure Functions
● Higher Order Functions (+Lambdas)
● Immutability
● Recursion
● Laziness
● map/filter/reduce/zip/flatMap
● Currying
20. Laziness
● Evaluation is deferred to the last possible moment
● Avoids needless calculations
● Working with infinite data structures
● Works very well with declarative programming
28. Concepts
● Declarative vs. Imperative
● Pure Functions
● Higher Order Functions (+Lambdas)
● Immutability
● Recursion
● Laziness
● map/filter/reduce/zip/flatMap
● Currying
29. Currying
● Concept by Haskell Curry
● Translating a function that takes multiple arguments into
a sequence of functions which all take 1 argument
● e.g.: add(a, b) AND add(a)(b)
● Improves reusability and composition
● In some languages (Haskell, F#) functions are curried by
default
39. Immutability in practice
● Data Structures don’t necessarily need to be persistent
in nature
● Use map / filter / reduce
● Examples in JS:
40. Maybe / Optional
● Pattern for handling absent (e.g.: Null) values
● Avoid annoying if (x==null) checks
● Great for declarative API’s
● Your business logic doesn’t need to deal with null
values, it can just use Maybe()’s
○ At the end, when the actual value is needed, the Maybe can be
evaluated and the null can be handled