* [NTG-context] \ifnum with two \recurselevel
@ 2025-05-08 17:02 Pablo Rodriguez via ntg-context
2025-05-08 19:02 ` [NTG-context] " Hans Hagen via ntg-context
0 siblings, 1 reply; 5+ messages in thread
From: Pablo Rodriguez via ntg-context @ 2025-05-08 17:02 UTC (permalink / raw)
To: ConTeXt users; +Cc: Pablo Rodriguez
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
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 5+ messages in thread
* [NTG-context] Re: \ifnum with two \recurselevel
2025-05-08 17:02 [NTG-context] \ifnum with two \recurselevel Pablo Rodriguez via ntg-context
@ 2025-05-08 19:02 ` Hans Hagen via ntg-context
2025-05-09 3:41 ` Pablo Rodriguez via ntg-context
0 siblings, 1 reply; 5+ messages in thread
From: Hans Hagen via ntg-context @ 2025-05-08 19:02 UTC (permalink / raw)
To: ntg-context; +Cc: Hans Hagen
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
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 5+ messages in thread
* [NTG-context] Re: \ifnum with two \recurselevel
2025-05-08 19:02 ` [NTG-context] " Hans Hagen via ntg-context
@ 2025-05-09 3:41 ` Pablo Rodriguez via ntg-context
2025-05-09 7:07 ` Hans Hagen
0 siblings, 1 reply; 5+ messages in thread
From: Pablo Rodriguez via ntg-context @ 2025-05-09 3:41 UTC (permalink / raw)
To: Hans Hagen via ntg-context; +Cc: Pablo Rodriguez
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
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 5+ messages in thread
* [NTG-context] Re: \ifnum with two \recurselevel
2025-05-09 3:41 ` Pablo Rodriguez via ntg-context
@ 2025-05-09 7:07 ` Hans Hagen
2025-05-09 14:14 ` Pablo Rodriguez via ntg-context
0 siblings, 1 reply; 5+ messages in thread
From: Hans Hagen @ 2025-05-09 7:07 UTC (permalink / raw)
To: ntg-context
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
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 5+ messages in thread
* [NTG-context] Re: \ifnum with two \recurselevel
2025-05-09 7:07 ` Hans Hagen
@ 2025-05-09 14:14 ` Pablo Rodriguez via ntg-context
0 siblings, 0 replies; 5+ messages in thread
From: Pablo Rodriguez via ntg-context @ 2025-05-09 14:14 UTC (permalink / raw)
To: ntg-context; +Cc: Pablo Rodriguez
On 5/9/25 09:07, Hans Hagen wrote:
>> [...]
>> 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
Many thanks for your info, Hans.
I would have never discovered this by myself.
Pablo
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-05-09 14:18 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-05-08 17:02 [NTG-context] \ifnum with two \recurselevel Pablo Rodriguez via ntg-context
2025-05-08 19:02 ` [NTG-context] " Hans Hagen via ntg-context
2025-05-09 3:41 ` Pablo Rodriguez via ntg-context
2025-05-09 7:07 ` Hans Hagen
2025-05-09 14:14 ` Pablo Rodriguez via ntg-context
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).