"매 function이 first-class — 매 computation은 immutable value 의 transformation". 매 FP는 lambda calculus(Church 1936)에서 시작, Haskell/ML/Lisp 통해 academic 으로, 매 React/Redux/Rx 의 mainstream 침투. 2026 mainstream language 모두 FP feature 흡수 (lambdas, map/filter, immutable, pattern match).
매 핵심
매 Pillars
Pure function: 매 same input → same output, no side effect
Immutability: 매 data 변경 대신 new value 생성
First-class function: 매 function = value (pass, return, store)
Referential transparency: 매 expression을 value로 substitute 가능
Higher-order function: 매 function in/out
매 Type system 매력
ADT (algebraic data types): sum (Either, Option) + product (tuple, record)
Pattern matching: 매 exhaustive case analysis
Type inference: 매 Hindley-Milner (ML, Haskell, Rust)
Typeclasses (Haskell) / Traits (Rust) / Type classes (Scala)
dataTreea=Leaf|Node(Treea)a(Treea)insert::Orda=>a->Treea->TreeainsertxLeaf=NodeLeafxLeafinsertxt@(Nodelvr)|x<v=Node(insertxl)vr|x>v=Nodelv(insertxr)|otherwise=t-- 매 IO monad: side effect 격리main::IO()main=doputStrLn"Enter name:"name<-getLineputStrLn$"Hello, "++name
Rust — iterators + Option
fnprocess(nums: Vec<i32>)-> Vec<i32>{nums.iter().filter(|&&x|x>0).map(|&x|x*x).take(10).collect()}// 매 Option chaining (no null)
fnfind_user(id: u64)-> Option<String>{db.get(id).and_then(|u|u.email).map(|e|e.to_lowercase())}
Scala — case class + pattern match
sealedtraitShapecaseclassCircle(r:Double)extendsShapecaseclassRect(w:Double,h:Double)extendsShapedefarea(s:Shape):Double=smatch{caseCircle(r)=>math.Pi*r*rcaseRect(w,h)=>w*h}// 매 immutable List + fold
valsum=List(1,2,3,4).foldLeft(0)(_+_)
TypeScript — immutable + HOF
// 매 readonly + pipe
constpipe=<T>(...fns: Array<(x: T)=>T>)=>(x: T):T=>fns.reduce((v,f)=>f(v),x);constaddOne=(n: number)=>n+1;constdouble=(n: number)=>n*2;constpipeline=pipe<number>(addOne,double);console.log(pipeline(3));// 8
// 매 Result type (avoid throw)
typeResult<T,E>={ok: true;value: T}|{ok: false;error: E};
Haskell — Functor / Monad
-- 매 Maybe monad: null-safe chainsafeDivide::Double->Double->MaybeDoublesafeDivide_0=NothingsafeDividexy=Just(x/y)calc::MaybeDoublecalc=doa<-safeDivide102b<-safeDividea0-- 매 short-circuit Nothingreturn(b+1)-- 매 result: Nothing
fromfunctoolsimportreduce,partial,lru_cache# 매 immutable transform@lru_cache(maxsize=None)deffib(n:int)->int:returnnifn<2elsefib(n-1)+fib(n-2)# 매 currying via partialmultiply=lambdax,y:x*ydouble=partial(multiply,2)print(list(map(double,[1,2,3])))# [2, 4, 6]# 매 reduceproduct=reduce(lambdaa,b:a*b,[1,2,3,4],1)