Functional Programming is a declarative programming paradigm that treats computation as the evaluation of mathematical functions, emphasizing immutability, pure functions, and avoiding side effects. Unlike imperative programming which focuses on how to execute step-by-step instructions, functional programming focuses on what to compute by composing functions. At its core lies the principle that data flows through transformations rather than being mutated in place, enabling powerful abstractions like higher-order functions, lazy evaluation, and referential transparency that make code more predictable, testable, and easier to reason about—especially in concurrent and parallel environments.
What This Cheat Sheet Covers
This topic spans 14 focused tables and 113 indexed concepts. Below is a complete table-by-table outline of this topic, spanning foundational concepts through advanced details.
Table 1: Core Principles
| Principle | Example | Description |
|---|---|---|
def add(x, y): return x + y | Function that always returns the same output for the same inputs and produces no side effects (no state changes, I/O, or mutations). | |
orig = [1, 2, 3]new = orig + [4] | • Data cannot be modified after creation • operations return new copies rather than mutating existing values. | |
f(x) = x * 2y = f(3) # always 6 | • Expression can be replaced with its value without changing program behavior • enables equational reasoning. | |
def apply(f, x): return f(x) | Functions are treated as values—can be assigned to variables, passed as arguments, and returned from functions. |