Difference between revisions of "Command/dostepwiserecurse"
< Command
Jump to navigation
Jump to search
(Create entire page) |
(looplevel --> recurselevel) |
||
Line 60: | Line 60: | ||
** {{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. |
Revision as of 09:59, 14 June 2012
\dostepwiserecurse
Syntax
\dostepwiserecurse{start}{stop}{step}{commands} | |
{start} | Initial value of recurselevel |
{stop} | Stop when recurselevel is higher than this (or when lower, if step is negative) |
{step} | Increment recurselevel by this much after each iteration |
{commands} | Commands or text to repeat |
Description
Repeat something for start, start + step, start + 2*step, ..., continuing until stop is exceeded.
Example
Counting down: \dostepwiserecurse{10}{4}{-2} {\recurselevel...\ } Counting stopped. Counting down again: \dostepwiserecurse{10}{5}{-2} {\recurselevel...\ } Counting stopped.
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: