# Template:Iterate

{{subst:x{{{1}}}|{{subst:substifx}}}}{{{2}}}{{subst:x{{{1}}}|{{subst:rightbraces}}}}

Template documentation

This template works with various recursive conversion templates, simulating the process of "saving a page n times".

Use
{{subst:iterate|times|{{subst:template| arguments}} }}, whenever Template:Xtimes, e.g. Template:X4, exists.
For example, using Template:Tsubst
{{subst:iterate|3|{{subst:tsubst}} }} gives after one save the wikitext

{{subst:#if:x|{{subst:#if:x|{{subst:#if:x|a{{subst:tsubst|b}}c }}}}}}

and after another save:

aaaaa{{subst:tsubst|b}}ccccc

For example, using Template:Square root
{{subst:iterate|3|{{subst:square root|5|1}} }} gives after one save the wikitext

{{subst:#if:x|{{subst:#if:x|{{subst:#if:x|{{subst:square root|5|3}}<br>1 }}}}}}

and after another save:

{{subst:square root|5|2.2360679775}}<br>2.23606889564<br>2.2380952381<br>2.33333333333<br>3<br>1

And
{{subst:#if:x|{{subst:iterate|3|{{subst:square root|5|1}} }} }} gives

{{subst:square root|5|2.2360679775}}<br>2.23606889564<br>2.2380952381<br>2.33333333333<br>3<br>1 in one edit.

Thus times is the number of extra conversions (in this case: improvements of the approximation of the square root): in the first case 2 edits and 3 extra is 5, in the second 1 edit, 1 extra for the #if, and 3 extra due to Template:Iterate, is also 5.

And, using Template:Countdown
{{subst:iterate|7|{{subst:countdown|{{subst:pipeN|7}}|7}}}} gives:

<br>1 |<br>2 |<br>3 |<br>4 |<br>5 |<br>6 |<br>7 | in two saves.

And
{{subst:#if:x|{{subst:iterate|7|{{subst:countdown|{{subst:pipe8}}|7}}}}}} gives

1 |
2 |
3 |
4 |
5 |
6 |
7 | in one save.

Note: countdown already iterates until 0 in 2 saves, so template:iterate is only useful with countdown if we want to stop before we reach 0, or to produce special characters like these pipes.

Substituting this template produces one or more new substitution template calls, allowing recursive change of a page, see Help:Recursive conversion of wikitext.