Difference between revisions of "Command/recursedepth"
< Command
Jump to navigation
Jump to search
(Create entire page) |
|||
(One intermediate revision by one other user not shown) | |||
Line 3: | Line 3: | ||
|attributes= | |attributes= | ||
}} | }} | ||
+ | |||
+ | == [[Help:Reference|Syntax]] (autogenerated) == | ||
+ | <syntax>recursedepth</syntax> | ||
== [[Help:Reference|Syntax]] == | == [[Help:Reference|Syntax]] == | ||
Line 14: | Line 17: | ||
== Description == | == Description == | ||
− | The nesting depth in the case of nested {{cmd|dorecurse}} | + | The nesting depth in the case of nested {{cmd|dorecurse}}, |
− | {{cmd|dostepwiserecurse}} | + | {{cmd|dostepwiserecurse}}, and {{cmd|doloop}}. |
== Example == | == Example == | ||
<context source=yes> | <context source=yes> | ||
− | \dorecurse{2} | + | \dorecurse{2}{ |
− | + | \recursedepth.\recurselevel:\crlf | |
− | \dorecurse{3} | + | ---\dorecurse{3} |
{\recursedepth.\recurselevel\ } | {\recursedepth.\recurselevel\ } | ||
− | \crlf} | + | \crlf |
+ | ---\doloop | ||
+ | {\recursedepth.\recurselevel\ | ||
+ | \ifnum \recurselevel=2 \exitloop \fi} | ||
+ | \crlf | ||
+ | } | ||
</context> | </context> | ||
Line 37: | Line 45: | ||
** {{cmd|exitloop}} to exit a loop. | ** {{cmd|exitloop}} to exit a loop. | ||
** {{cmd|exitloopnow}} to immediately exit a loop. | ** {{cmd|exitloopnow}} to immediately exit a loop. | ||
− | ** {{cmd| | + | ** {{cmd|recurselevel}} to know which iteration the loop is in. |
− | ** {{cmd| | + | ** {{cmd|recursedepth}} to know how many nested loops deep we are. |
* {{cmd|input}} is also often used to produce dummy text. | * {{cmd|input}} is also often used to produce dummy text. | ||
* [[Programming_in_LuaTeX#Loops_without_worrying_about_expansion|LuaTeX]] for heavier-duty looping and iterating. | * [[Programming_in_LuaTeX#Loops_without_worrying_about_expansion|LuaTeX]] for heavier-duty looping and iterating. |
Latest revision as of 16:30, 11 November 2019
\recursedepth
Syntax (autogenerated)
\recursedepth |
Syntax
\recursedepth |
Description
The nesting depth in the case of nested \dorecurse, \dostepwiserecurse, and \doloop.
Example
\dorecurse{2}{ \recursedepth.\recurselevel:\crlf ---\dorecurse{3} {\recursedepth.\recurselevel\ } \crlf ---\doloop {\recursedepth.\recurselevel\ \ifnum \recurselevel=2 \exitloop \fi} \crlf }
See also
- System Macros/Loops and Recursion
- Looping a fixed number of times
- \dorecurse for iterating from 1 to n.
- \dostepwiserecurse for iteration with arbitrary start, end, and step.
- \recurselevel for the iteration number.
- \recursedepth for the iteration depth, in the case of nested \dorecurse and co.
- 'While' loops with exit conditions
- \doloop for a loop that repeats until exited.
- \exitloop to exit a loop.
- \exitloopnow to immediately exit a loop.
- \recurselevel to know which iteration the loop is in.
- \recursedepth to know how many nested loops deep we are.
- \input is also often used to produce dummy text.
- LuaTeX for heavier-duty looping and iterating.
Help from ConTeXt-Mailinglist/Forum
All issues with: