Professional Documents
Culture Documents
Functional Programming
Outline
n := x;
a := 1;
while n>0 do
begin
a := a * n;
n := n – 1;
end;
…
Declarative Languages
fac x 1
where fac n a
= if n>0 then fac(n-1) (a*n)
else a
n and a are examples of carrying the state
around explicitly
recursive structure mimics the looping
behavior
What vs. How