next | previous | forward | backward | up | top | index | toc | home

recursionDepth -- the current recursion depth

Synopsis

Description

i1 : recursionDepth()

o1 = 2
i2 : f = x -> recursionDepth()

o2 = f

o2 : FunctionClosure
i3 : f()

o3 = 3
i4 : g = x -> f()

o4 = g

o4 : FunctionClosure
i5 : g()

o5 = 4
Tail recursion optimization may be in effect, so there the answer may not always be what you expect.
i6 : r = i -> if i == 100 then recursionDepth() else r(i+1)

o6 = r

o6 : FunctionClosure
i7 : r 0

o7 = 3

See also