<?xml version="1.0" encoding="utf-8" ?> <!-- for emacs: -*- coding: utf-8 -*- --> <!-- Apache may like this line in the file .htaccess: AddCharset utf-8 .html --> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg-flat.dtd" > <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head><title>recursionDepth -- the current recursion depth</title> <link rel="stylesheet" type="text/css" href="../../../../Macaulay2/Style/doc.css"/> </head> <body> <table class="buttons"> <tr> <td><div><a href="_recursion__Limit.html">next</a> | <a href="_real__Part.html">previous</a> | <a href="_recursion__Limit.html">forward</a> | <a href="_real__Part.html">backward</a> | up | <a href="index.html">top</a> | <a href="master.html">index</a> | <a href="toc.html">toc</a> | <a href="http://www.math.uiuc.edu/Macaulay2/">Macaulay2 web site</a></div> </td> </tr> </table> <hr/> <div><h1>recursionDepth -- the current recursion depth</h1> <div class="single"><h2>Synopsis</h2> <ul><li><div class="list"><dl class="element"><dt class="heading">Usage: </dt><dd class="value"><div><tt>recursionDepth()</tt></div> </dd></dl> </div> </li> <li><div class="single">Outputs:<ul><li><span><span>an <a href="___Z__Z.html">integer</a></span>, the current depth of recursion in the interpreter</span></li> </ul> </div> </li> </ul> </div> <div class="single"><h2>Description</h2> <div><table class="examples"><tr><td><pre>i1 : recursionDepth() o1 = 0</pre> </td></tr> <tr><td><pre>i2 : f = x -> recursionDepth() o2 = f o2 : FunctionClosure</pre> </td></tr> <tr><td><pre>i3 : f() o3 = 1</pre> </td></tr> <tr><td><pre>i4 : g = x -> f() o4 = g o4 : FunctionClosure</pre> </td></tr> <tr><td><pre>i5 : g() o5 = 2</pre> </td></tr> </table> Tail recursion optimization may be in effect, so there the answer may not always be what you expect.<table class="examples"><tr><td><pre>i6 : r = i -> if i == 100 then recursionDepth() else r(i+1) o6 = r o6 : FunctionClosure</pre> </td></tr> <tr><td><pre>i7 : r 0 o7 = 1</pre> </td></tr> </table> </div> </div> <div class="single"><h2>See also</h2> <ul><li><span><a href="_recursion__Limit.html" title="set the limit on recursion">recursionLimit</a> -- set the limit on recursion</span></li> </ul> </div> </div> </body> </html>