Macaulay2 » Documentation
Packages » Macaulay2Doc :: recursionDepth
next | previous | forward | backward | up | index | toc

recursionDepth -- the current recursion depth

Synopsis

Description

i1 : recursionDepth()

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

o2 = f

o2 : FunctionClosure
i3 : f()

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

o4 = g

o4 : FunctionClosure
i5 : g()

o5 = 16
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 = 15

See also

For the programmer

The object recursionDepth is a compiled function.