
Dear list, I have the following sample code: \starttext \startTEXpage[offset=1dk] \dostepwiserecurse{2}{6}{1}{\edef\AbC{\recurselevel}% \dostepwiserecurse{2}{7}{1}{%\AbC.\recurselevel\ /\ \ifnum\AbC < \recurselevel% \AbC:\recurselevel\ \|\| \fi} \\} \stopTEXpage \stoptext I would like to only get the numbers in the form first:second loops if and only if the value of the first loop is less than the value from the second loop. I think this should be simple, but I don’t get it with any of these conditionals: \ifnum\AbC < \recurselevel \ifnum\recurselevel > \AbC Sorry for the stupid question, but what I am missing here? Many thanks for your help, Pablo

On 5/8/2025 7:02 PM, Pablo Rodriguez via ntg-context wrote:
Dear list,
I have the following sample code:
\starttext \startTEXpage[offset=1dk] \dostepwiserecurse{2}{6}{1}{\edef\AbC{\recurselevel}% \dostepwiserecurse{2}{7}{1}{%\AbC.\recurselevel\ /\ \ifnum\AbC < \recurselevel% \AbC:\recurselevel\ \|\| \fi} \\} \stopTEXpage \stoptext
I would like to only get the numbers in the form first:second loops if and only if the value of the first loop is less than the value from the second loop.
I think this should be simple, but I don’t get it with any of these conditionals:
\ifnum\AbC < \recurselevel
\ifnum\recurselevel > \AbC
Sorry for the stupid question, but what I am missing here?
Many thanks for your help,
These % after the comparison make tex scan on for the end of a number (a \relax of space ends the scan). You can do this: \starttext \startTEXpage[offset=1dk] \dostepwiserecurse{2}{6}{1}{% \dostepwiserecurse{2}{7}{1}{% \ifnum#1<##1\relax #1:##1\ \|\|% \fi }% \\% } \stopTEXpage \stoptext ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------

On 5/8/25 21:02, Hans Hagen via ntg-context wrote:
[...] These % after the comparison make tex scan on for the end of a number (a \relax of space ends the scan). You can do this:
Many thanks for your reply, Hans. With your sample, I see that some crazy things (such as the following) are possible: \starttext \dorecurse{2}{% \dorecurse{3}{% \dorecurse{4}{% \dorecurse{5}{% \dorecurse{6}{% #1:##1:####1:########1:################1 }\\ }\blank[.25st]}\blank[.5st]}\blank[1st]} \stoptext I mean, accessing different levels of recursion in nested loops. Being a very special trick for really corner cases, is there something to be considered when using it? Many thanks for your help, Pablo

On 5/9/2025 5:41 AM, Pablo Rodriguez via ntg-context wrote:
On 5/8/25 21:02, Hans Hagen via ntg-context wrote:
[...] These % after the comparison make tex scan on for the end of a number (a \relax of space ends the scan). You can do this:
Many thanks for your reply, Hans.
With your sample, I see that some crazy things (such as the following) are possible:
\starttext \dorecurse{2}{% \dorecurse{3}{% \dorecurse{4}{% \dorecurse{5}{% \dorecurse{6}{% #1:##1:####1:########1:################1 }\\ }\blank[.25st]}\blank[.5st]}\blank[1st]} \stoptext
I mean, accessing different levels of recursion in nested loops.
Being a very special trick for really corner cases, is there something to be considered when using it?
only imagination ... try #2 ##2 etc .. these #1 things are basically references to macro arguments \dorecurse{1}{% \dorecurse{3}{% \dorecurse{3}{% \dorecurse{3}{% \dorecurse{3}{% % #1:##1:####1:########1:################1 #2:##2:####2:########2:################2 }\\ } \blank[.25st] } \blank[.5st] } \blank[1st] } \page or go wild with \localcontrolledrepeat 1 { \localcontrolledrepeat 3 { \localcontrolledrepeat 3 { \localcontrolledrepeat 3 { \localcontrolledrepeat 3 { \the\previousloopiterator4:% \the\previousloopiterator3:% \the\previousloopiterator2:% \the\previousloopiterator1:% \the\previousloopiterator0 % }\\ } \blank[.25st] } \blank[.5st] } \blank[1st] } \page or maybe: \edef\foo{% \expandedrepeat 1 { \expandedrepeat 3 { \expandedrepeat 3 { \expandedrepeat 3 { \expandedrepeat 3 { \the\previousloopiterator4:% \the\previousloopiterator3:% \the\previousloopiterator2:% \the\previousloopiterator1:% \the\previousloopiterator0 % }\\ } \blank[.25st] } \blank[.5st] } \blank[1st] } } \foo \meaningfull\foo enough in there for a rainy day Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
participants (3)
-
Hans Hagen
-
Hans Hagen
-
Pablo Rodriguez