Yes, that would work for increment, and I should have seen that.
I don’t see how that would help, except in generating an example. Am I missing something?
Thank you both for the help. I’m afraid I oversimplified the problem, thinking that if I solved increment, I could easily apply it to add(2)
, add(3)
, add(4)
, subtract(1)
, subtract(2)
, subtract(3)
, and so on. @springer: your edit is an elegant way to deal with increment, but I don’t think it expands to the general problem.
Perhaps this is a better phrasing of my general problem:
Is there a simple wikitext way to add or subtract numbers modulo some number – let’s say 5
– given that I want values in the range 1 - 5
and not 0 - 4
, as remainder
generates?
This works, but feels inelegant:
<$let addend=2 modulus=5>
{{{ [range<modulus>] :map[add<addend>remainder<modulus>] :map[match[0]then<modulus>else{!!title}] }}}
</$let>
yielding
3 4 5 1 2
The range
call (or my earlier enlist
) is just for demonstration. I will have a number, and would like to add or subtract 1 (and/or 2, 3, or other small integers) from each of them, modulo some value, but returning positive numbers and not zero.
If there’s nothing more elegant, this is not terrible. But I feel as though I’m likely missing a simpler approach.