Notes/Functional Programming/Introduction to Functional Programming.md
2024-12-07 21:07:38 +01:00

587 B

type
mixed

Definition

  • Pure mathematical functions
  • Declarative paradigm
    • Instead of writing step-by-step, we define the desired outcome
  • Immutable data
  • => No/Less side effects
  • Programs are easier to verify
    • We can mathematically prove the algorithms

Lazy vs. Strict

  • Calculations are delayed until the results are actually needed

Example

Imagine a list of numbers, but you only need the first one that meets a condition. With lazy evaluation, the program stops processing the list as soon as it finds the result, instead of checking every number.