You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
David Pollak edited this page Jan 13, 2012
·
1 revision
Test local function
This is an example of a local function inside the f function. The fact function is local (it is not visible outside f and cannot be called outside f). Further, the n parameter to f is shadowed in fact.
// calculate the factorial of n
f n =
fact n = if n == 0 then 1 else n * fact(n - 1)
fact n
// invoke the function
res = f 8