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
More Scoping
Another test for scoping. We assign a local variable moo to the result of the internal fact computation and then return moo.
fact n = n & "hello" // propper scoping this fact is not the inner fact
f n = /* test that the function closes over local scope */
fact n = if n == 0 then 1 else n * fact(n - 1)
moo = fact n /* This is the local reference to 'n' */
moo // one level of indirection -- a local variable
res = f 7 // == 5040