ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* \dorecurse and \recurselevel in Natural Tables
@ 2009-03-04 19:35 Curious Learn
  2009-03-04 19:53 ` luigi scarso
  2009-03-04 20:35 ` Wolfgang Schuster
  0 siblings, 2 replies; 31+ messages in thread
From: Curious Learn @ 2009-03-04 19:35 UTC (permalink / raw)
  To: ntg-context

Can someone please explain why the second example below works but the first does
not work? 
Thanks very much.

\starttext                         

\bTABLE
\dorecurse{5}
{\bTR \bTD \recurselevel. \eTD 
	  \bTD \recurselevel  \eTD\eTR}
\eTABLE 

\dorecurse{2}
{\recurselevel. \recurselevel\crlf}

\stoptext    



___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: \dorecurse and \recurselevel in Natural Tables
  2009-03-04 19:35 \dorecurse and \recurselevel in Natural Tables Curious Learn
@ 2009-03-04 19:53 ` luigi scarso
  2009-03-04 20:04   ` luigi scarso
  2009-03-05  0:17   ` luigi scarso
  2009-03-04 20:35 ` Wolfgang Schuster
  1 sibling, 2 replies; 31+ messages in thread
From: luigi scarso @ 2009-03-04 19:53 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On Wed, Mar 4, 2009 at 8:35 PM, Curious Learn <curiouslearn@gmail.com> wrote:
> Can someone please explain why the second example below works but the first does
> not work?
> Thanks very much.
>
> \starttext
>
> \bTABLE
> \dorecurse{5}
> {\bTR \bTD \recurselevel. \eTD
>          \bTD \recurselevel  \eTD\eTR}
> \eTABLE
>
> \dorecurse{2}
> {\recurselevel. \recurselevel\crlf}
>
> \stoptext
works ok here with latest minimals
This is LuaTeX, Version snapshot-0.35.0-2009022702 (Web2C 7.5.7)
ConTeXt  ver: 2008.11.10 21:40 MKIV  fmt: 2009.3.4  int: english/english


>
>
>
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
>
> maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
> archive  : https://foundry.supelec.fr/projects/contextrev/
> wiki     : http://contextgarden.net
> ___________________________________________________________________________________
>



-- 
luigi
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: \dorecurse and \recurselevel in Natural Tables
  2009-03-04 19:53 ` luigi scarso
@ 2009-03-04 20:04   ` luigi scarso
  2009-03-05  0:17   ` luigi scarso
  1 sibling, 0 replies; 31+ messages in thread
From: luigi scarso @ 2009-03-04 20:04 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On Wed, Mar 4, 2009 at 8:53 PM, luigi scarso <luigi.scarso@gmail.com> wrote:
> On Wed, Mar 4, 2009 at 8:35 PM, Curious Learn <curiouslearn@gmail.com> wrote:
>> Can someone please explain why the second example below works but the first does
>> not work?
>> Thanks very much.
>>
>> \starttext
>>
>> \bTABLE
>> \dorecurse{5}
>> {\bTR \bTD \recurselevel. \eTD
>>          \bTD \recurselevel  \eTD\eTR}
>> \eTABLE
>>
>> \dorecurse{2}
>> {\recurselevel. \recurselevel\crlf}
>>
>> \stoptext
> works ok here with latest minimals
> This is LuaTeX, Version snapshot-0.35.0-2009022702 (Web2C 7.5.7)
> ConTeXt  ver: 2008.11.10 21:40 MKIV  fmt: 2009.3.4  int: english/english
and also OK with minimals beta

This is LuaTeX, Version snapshot-0.35.0

(test-curios.tex

ConTeXt  ver: 2009.03.04 17:30 MKIV  fmt: 2009.3.4  int: english/english

-- 
luigi
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: \dorecurse and \recurselevel in Natural Tables
  2009-03-04 19:35 \dorecurse and \recurselevel in Natural Tables Curious Learn
  2009-03-04 19:53 ` luigi scarso
@ 2009-03-04 20:35 ` Wolfgang Schuster
  2009-03-04 20:57   ` Curious Learn
  1 sibling, 1 reply; 31+ messages in thread
From: Wolfgang Schuster @ 2009-03-04 20:35 UTC (permalink / raw)
  To: mailing list for ConTeXt users


Am 04.03.2009 um 20:35 schrieb Curious Learn:

> Can someone please explain why the second example below works but  
> the first does
> not work?
> Thanks very much.
>
> \starttext
>
> \bTABLE
> \dorecurse{5}
> {\bTR \bTD \recurselevel. \eTD
> 	  \bTD \recurselevel  \eTD\eTR}
> \eTABLE


\bTABLE
\dorecurse{5}{\bTR\expanded{\bTD\recurselevel\eTD}\eTR}
\eTABLE

Wolfgang

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: \dorecurse and \recurselevel in Natural Tables
  2009-03-04 20:35 ` Wolfgang Schuster
@ 2009-03-04 20:57   ` Curious Learn
  2009-03-04 21:11     ` Wolfgang Schuster
  0 siblings, 1 reply; 31+ messages in thread
From: Curious Learn @ 2009-03-04 20:57 UTC (permalink / raw)
  To: ntg-context

Wolfgang Schuster <schuster.wolfgang <at> googlemail.com> writes:

> 
> \bTABLE
> \dorecurse{5}{\bTR\expanded{\bTD\recurselevel\eTD}\eTR}
> \eTABLE
> 
> Wolfgang

As your other solutions, this worked great. I suppose I have to use \expanded
for every \bTD \eTD pair. Can you please explain why this is necessary or point
me to a document that contains the explanation.

Thanks very much.


___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: \dorecurse and \recurselevel in Natural Tables
  2009-03-04 20:57   ` Curious Learn
@ 2009-03-04 21:11     ` Wolfgang Schuster
  2009-03-04 21:43       ` Aditya Mahajan
  2009-03-04 22:17       ` Curious Learn
  0 siblings, 2 replies; 31+ messages in thread
From: Wolfgang Schuster @ 2009-03-04 21:11 UTC (permalink / raw)
  To: mailing list for ConTeXt users


Am 04.03.2009 um 21:57 schrieb Curious Learn:

> Wolfgang Schuster <schuster.wolfgang <at> googlemail.com> writes:
>
>> \bTABLE
>> \dorecurse{5}{\bTR\expanded{\bTD\recurselevel\eTD}\eTR}
>> \eTABLE
>
> As your other solutions, this worked great. I suppose I have to use  
> \expanded
> for every \bTD \eTD pair.

Not really.

\bTABLE
\dorecurse{5}{\bTR\bTD#1\eTD\eTR}
\eTABLE

Wolfgang

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: \dorecurse and \recurselevel in Natural Tables
  2009-03-04 21:11     ` Wolfgang Schuster
@ 2009-03-04 21:43       ` Aditya Mahajan
  2009-03-04 21:51         ` Wolfgang Schuster
  2009-03-04 22:17       ` Curious Learn
  1 sibling, 1 reply; 31+ messages in thread
From: Aditya Mahajan @ 2009-03-04 21:43 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On Wed, 4 Mar 2009, Wolfgang Schuster wrote:

> \bTABLE
> \dorecurse{5}{\bTR\bTD#1\eTD\eTR}
> \eTABLE

This is evil genious!

Aditya
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: \dorecurse and \recurselevel in Natural Tables
  2009-03-04 21:43       ` Aditya Mahajan
@ 2009-03-04 21:51         ` Wolfgang Schuster
  0 siblings, 0 replies; 31+ messages in thread
From: Wolfgang Schuster @ 2009-03-04 21:51 UTC (permalink / raw)
  To: mailing list for ConTeXt users


Am 04.03.2009 um 22:43 schrieb Aditya Mahajan:

> On Wed, 4 Mar 2009, Wolfgang Schuster wrote:
>
>> \bTABLE
>> \dorecurse{5}{\bTR\bTD#1\eTD\eTR}
>> \eTABLE
>
> This is evil genious!


Can be used nested too.

\starttext
\bTABLE
\dorecurse{5}
   {\bTR
    \dorecurse{5}{\bTD#1:##1\eTD}
    \eTR}
\eTABLE
\stoptext

Wolfgang

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: \dorecurse and \recurselevel in Natural Tables
  2009-03-04 21:11     ` Wolfgang Schuster
  2009-03-04 21:43       ` Aditya Mahajan
@ 2009-03-04 22:17       ` Curious Learn
  2009-03-04 22:35         ` Wolfgang Schuster
  1 sibling, 1 reply; 31+ messages in thread
From: Curious Learn @ 2009-03-04 22:17 UTC (permalink / raw)
  To: ntg-context


> Not really.
> 
> \bTABLE
> \dorecurse{5}{\bTR\bTD#1\eTD\eTR}
> \eTABLE
> 
> Wolfgang
> 

Awesome!!!! How does one learn these things? Is this Tex programming or Context
programming.

Thanks very much.




___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: \dorecurse and \recurselevel in Natural Tables
  2009-03-04 22:17       ` Curious Learn
@ 2009-03-04 22:35         ` Wolfgang Schuster
  0 siblings, 0 replies; 31+ messages in thread
From: Wolfgang Schuster @ 2009-03-04 22:35 UTC (permalink / raw)
  To: mailing list for ConTeXt users


Am 04.03.2009 um 23:17 schrieb Curious Learn:

>> Not really.
>>
>> \bTABLE
>> \dorecurse{5}{\bTR\bTD#1\eTD\eTR}
>> \eTABLE
>>
>> Wolfgang
>
> Awesome!!!! How does one learn these things?

Follow the mailing list and read parts of the source.

> Is this Tex programming or Context programming.

It's a ConTeXt future.

You can use inside of \dorecurse #1 to get the expanded level
and #2 to get the recurse depth.

Wolfgang

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: \dorecurse and \recurselevel in Natural Tables
  2009-03-04 19:53 ` luigi scarso
  2009-03-04 20:04   ` luigi scarso
@ 2009-03-05  0:17   ` luigi scarso
  2009-03-05 11:09     ` Wolfgang Schuster
  1 sibling, 1 reply; 31+ messages in thread
From: luigi scarso @ 2009-03-05  0:17 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On Wed, Mar 4, 2009 at 8:53 PM, luigi scarso <luigi.scarso@gmail.com> wrote:
> On Wed, Mar 4, 2009 at 8:35 PM, Curious Learn <curiouslearn@gmail.com> wrote:
>> Can someone please explain why the second example below works but the first does
>> not work?
>> Thanks very much.
>>
>> \starttext
>>
>> \bTABLE
>> \dorecurse{5}
>> {\bTR \bTD \recurselevel. \eTD
>>          \bTD \recurselevel  \eTD\eTR}
>> \eTABLE
>>
>> \dorecurse{2}
>> {\recurselevel. \recurselevel\crlf}
>>
>> \stoptext

> works ok here with latest minimals
> This is LuaTeX, Version snapshot-0.35.0-2009022702 (Web2C 7.5.7)
> ConTeXt  ver: 2008.11.10 21:40 MKIV  fmt: 2009.3.4  int: english/english
oops...I forget my code
sorry



\starttext
%%% TeX version
\bTABLE
\dorecurse{5}
{\bTR\expandafter \bTD \recurselevel. \eTD\expandafter
         \bTD \recurselevel  \eTD\eTR}
\eTABLE

\dorecurse{2}
{\recurselevel. \recurselevel\crlf}

%%% luatex version
\startluacode
    tprint = function(s) tex.sprint(tex.ctxcatcodes,s) end
    tprint('\\bTABLE')
    for j = 1,5 do
        tprint('\\bTR')
        tprint('\\bTD' .. j .. '.' .. '\\eTD' .. '\\bTD' .. j .. '\\eTD')
        tprint('\\eTR')
    end
    tprint('\\eTABLE')
\stopluacode
\stoptext


-- 
luigi
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: \dorecurse and \recurselevel in Natural Tables
  2009-03-05  0:17   ` luigi scarso
@ 2009-03-05 11:09     ` Wolfgang Schuster
  2009-03-05 11:27       ` luigi scarso
  0 siblings, 1 reply; 31+ messages in thread
From: Wolfgang Schuster @ 2009-03-05 11:09 UTC (permalink / raw)
  To: mailing list for ConTeXt users


Am 05.03.2009 um 01:17 schrieb luigi scarso:

> \starttext
> %%% TeX version
> \bTABLE
> \dorecurse{5}
> {\bTR\expandafter \bTD \recurselevel. \eTD\expandafter
>         \bTD \recurselevel  \eTD\eTR}
> \eTABLE
>
> \dorecurse{2}
> {\recurselevel. \recurselevel\crlf}

And you think it's a good idea to use \expandafter in your document?

\expanded is the tool for users to get this result without knowledge
about TeX internals and expansion, this is from core-ntb:

% permits \expanded{\bTD ... \eTD}

\unexpanded\def\eTR{}
\unexpanded\def\eTD{}
\unexpanded\def\eTH{}
\unexpanded\def\eTN{}

> %%% luatex version
> \startluacode
>    tprint = function(s) tex.sprint(tex.ctxcatcodes,s) end
>    tprint('\\bTABLE')
>    for j = 1,5 do
>        tprint('\\bTR')
>        tprint('\\bTD' .. j .. '.' .. '\\eTD' .. '\\bTD' .. j .. '\ 
> \eTD')
>        tprint('\\eTR')
>    end
>    tprint('\\eTABLE')
> \stopluacode
> \stoptext

Nice solution and real alternative for package writers to avoid  
\expandafter
and \expanded but nothing for a normal user, I should keep this in my  
mind.

Wolfgang

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: \dorecurse and \recurselevel in Natural Tables
  2009-03-05 11:09     ` Wolfgang Schuster
@ 2009-03-05 11:27       ` luigi scarso
  2009-03-05 12:00         ` Wolfgang Schuster
  2009-03-06  3:05         ` Aditya Mahajan
  0 siblings, 2 replies; 31+ messages in thread
From: luigi scarso @ 2009-03-05 11:27 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On Thu, Mar 5, 2009 at 12:09 PM, Wolfgang Schuster
<schuster.wolfgang@googlemail.com> wrote:
>
> Am 05.03.2009 um 01:17 schrieb luigi scarso:
>
>> \starttext
>> %%% TeX version
>> \bTABLE
>> \dorecurse{5}
>> {\bTR\expandafter \bTD \recurselevel. \eTD\expandafter
>>        \bTD \recurselevel  \eTD\eTR}
>> \eTABLE
>>
>> \dorecurse{2}
>> {\recurselevel. \recurselevel\crlf}
>
> And you think it's a good idea to use \expandafter in your document?
TeX  version, not context ... :)
btw
\expandafer is not so bad, if used moderatly .

>
> \expanded is the tool for users to get this result without knowledge
> about TeX internals and expansion, this is from core-ntb:
>
> % permits \expanded{\bTD ... \eTD}
>
> \unexpanded\def\eTR{}
> \unexpanded\def\eTD{}
> \unexpanded\def\eTH{}
> \unexpanded\def\eTN{}
yes, of course one need to know about \expandafter... so is not so different .
But it's context style.

>
>> %%% luatex version
>> \startluacode
>>   tprint = function(s) tex.sprint(tex.ctxcatcodes,s) end
>>   tprint('\\bTABLE')
>>   for j = 1,5 do
>>       tprint('\\bTR')
>>       tprint('\\bTD' .. j .. '.' .. '\\eTD' .. '\\bTD' .. j .. '\\eTD')
>>       tprint('\\eTR')
>>   end
>>   tprint('\\eTABLE')
>> \stopluacode
>> \stoptext
>
> Nice solution and real alternative for package writers to avoid \expandafter
> and \expanded but nothing for a normal user, I should keep this in my mind.
Are you sure ?
What is a normal user ?
As soon as you use \dorecurse , you become a programmer .

And sooner or later, everyone become a programmer, because it's
impossible to write a format that satisfied
all your needs .




-- 
luigi
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: \dorecurse and \recurselevel in Natural Tables
  2009-03-05 11:27       ` luigi scarso
@ 2009-03-05 12:00         ` Wolfgang Schuster
  2009-03-05 13:23           ` luigi scarso
  2009-03-06  3:05         ` Aditya Mahajan
  1 sibling, 1 reply; 31+ messages in thread
From: Wolfgang Schuster @ 2009-03-05 12:00 UTC (permalink / raw)
  To: mailing list for ConTeXt users


Am 05.03.2009 um 12:27 schrieb luigi scarso:

>> And you think it's a good idea to use \expandafter in your document?
> TeX  version, not context ... :)
> btw
> \expandafer is not so bad, if used moderatly .

But don't make a beginner used to it, e.g. Stefan Kottwitz mentioned a  
few
times how to append something to a existing macro in LaTeX forums and  
this
is what I try to avoid for people who don't know what they are doing.

http://texblog.net/latex-archive/plaintex/expandafter/

>> Nice solution and real alternative for package writers to avoid  
>> \expandafter
>> and \expanded but nothing for a normal user, I should keep this in  
>> my mind.
> Are you sure ?
> What is a normal user ?

People who want to use TeX to write a document but copy code from  
examples,
old list messages etc. but don't why they have to do it something like  
this.

> As soon as you use \dorecurse , you become a programmer .
>
> And sooner or later, everyone become a programmer, because it's
> impossible to write a format that satisfied
> all your needs .

OK, it's hard to write a fancy layout without defining your own header  
styles etc.
without a definition but use then as many high level contructs  
(\framed, \define, ...)
as possible and try to avoid things like \vbox or \expandafter.

Wolfgang

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: \dorecurse and \recurselevel in Natural Tables
  2009-03-05 12:00         ` Wolfgang Schuster
@ 2009-03-05 13:23           ` luigi scarso
  2009-03-05 13:52             ` Wolfgang Schuster
  0 siblings, 1 reply; 31+ messages in thread
From: luigi scarso @ 2009-03-05 13:23 UTC (permalink / raw)
  To: mailing list for ConTeXt users

> People who want to use TeX to write a document but copy code from examples,
> old list messages etc. but don't why they have to do it something like this.

> OK, it's hard to write a fancy layout without defining your own header
> styles etc.
> without a definition but use then as many high level contructs (\framed,
> \define, ...)
> as possible and try to avoid things like \vbox or \expandafter.

This is my point of view :
"use TeX to write a document" = "write a program in TeX  programming language"

TeX programming language is not like lua, python, c++ , java and so on;
TeX programming language is like m4, ie a macro language.

If you write a simple document (= a simple program) context
high-level const.s  will almost completly hide
the programming aspect ;
but it's impossible that context "high-level" cover *all* program; so
sooner or later one will
use lua(tex) expression (which can be a "natural" choice for most of
programmer but can be slow) ,
or ContTeXt macro (which can be less slow but not so natural ) ,
or even TeX macro - primitive .



>http://texblog.net/latex-archive/plaintex/expandafter/
hey, this is not a "moderate use of expandafter" as I intended ..
I dropped latex for similar examples .
In this situation
"please, grep setvalue base/*"



-- 
luigi
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: \dorecurse and \recurselevel in Natural Tables
  2009-03-05 13:23           ` luigi scarso
@ 2009-03-05 13:52             ` Wolfgang Schuster
  2009-03-05 14:23               ` luigi scarso
  0 siblings, 1 reply; 31+ messages in thread
From: Wolfgang Schuster @ 2009-03-05 13:52 UTC (permalink / raw)
  To: mailing list for ConTeXt users


Am 05.03.2009 um 14:23 schrieb luigi scarso:

>> http://texblog.net/latex-archive/plaintex/expandafter/
>
> hey, this is not a "moderate use of expandafter" as I intended ..
> I dropped latex for similar examples .
> In this situation
> "please, grep setvalue base/*"

??? I can't understand the relation between \setvalue and the  
expandafter
trick in the example on the webpage, setvalue hides the csname ...  
endcsname
part but the example tries to avoid the \let\oldmacro\macro \def 
\macro{\oldmacro...}
redefinition.

Wolfgang

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: \dorecurse and \recurselevel in Natural Tables
  2009-03-05 13:52             ` Wolfgang Schuster
@ 2009-03-05 14:23               ` luigi scarso
  2009-03-05 14:53                 ` Wolfgang Schuster
  0 siblings, 1 reply; 31+ messages in thread
From: luigi scarso @ 2009-03-05 14:23 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On Thu, Mar 5, 2009 at 2:52 PM, Wolfgang Schuster
<schuster.wolfgang@googlemail.com> wrote:
>
> Am 05.03.2009 um 14:23 schrieb luigi scarso:
>
>>> http://texblog.net/latex-archive/plaintex/expandafter/
>>
>> hey, this is not a "moderate use of expandafter" as I intended ..
>> I dropped latex for similar examples .
>> In this situation
>> "please, grep setvalue base/*"
>
> ??? I can't understand the relation between \setvalue and the expandafter
> trick in the example on the webpage, setvalue hides the csname ... endcsname
> part but the example tries to avoid the \let\oldmacro\macro
> \def\macro{\oldmacro...}
> redefinition.
I don't like the
\let\oldmacro\macro  \def\macro{\oldmacro...}
construct
because sometimes the \def\macro{\oldmacro...}
can cause unexpected behaviour

I prefear

\setvalue{quote small}{\quote\small}
{\getvalue{quote small} foo }


-- 
luigi
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: \dorecurse and \recurselevel in Natural Tables
  2009-03-05 14:23               ` luigi scarso
@ 2009-03-05 14:53                 ` Wolfgang Schuster
  2009-03-05 15:08                   ` luigi scarso
  0 siblings, 1 reply; 31+ messages in thread
From: Wolfgang Schuster @ 2009-03-05 14:53 UTC (permalink / raw)
  To: mailing list for ConTeXt users


Am 05.03.2009 um 15:23 schrieb luigi scarso:

> I prefear
>
> \setvalue{quote small}{\quote\small}
> {\getvalue{quote small} foo }

This is non trivial example, normally I would define a new quote  
command with

   \definedelimitedtext[quotesmall][quote]

but you above code can't be achieved with this because the results are  
either
small text or text with quotes at both sides but not a combination of  
them.

How about: \define\quotesmall{\groupedcommand{\quote\small}{}}

Wolfgang

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: \dorecurse and \recurselevel in Natural Tables
  2009-03-05 14:53                 ` Wolfgang Schuster
@ 2009-03-05 15:08                   ` luigi scarso
  0 siblings, 0 replies; 31+ messages in thread
From: luigi scarso @ 2009-03-05 15:08 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On Thu, Mar 5, 2009 at 3:53 PM, Wolfgang Schuster
<schuster.wolfgang@googlemail.com> wrote:
>
> Am 05.03.2009 um 15:23 schrieb luigi scarso:
>
>> I prefear
>>
>> \setvalue{quote small}{\quote\small}
>> {\getvalue{quote small} foo }
>
> This is non trivial example, normally I would define a new quote command
> with
>
>  \definedelimitedtext[quotesmall][quote]
>
> but you above code can't be achieved with this because the results are
> either
> small text or text with quotes at both sides but not a combination of them.
>
> How about: \define\quotesmall{\groupedcommand{\quote\small}{}}
sound good.
Does it work \setvalue{quote:small}{\groupedcommand{\quote\small}{}}
?

-- 
luigi
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: \dorecurse and \recurselevel in Natural Tables
  2009-03-05 11:27       ` luigi scarso
  2009-03-05 12:00         ` Wolfgang Schuster
@ 2009-03-06  3:05         ` Aditya Mahajan
  2009-03-06  6:41           ` luigi scarso
                             ` (4 more replies)
  1 sibling, 5 replies; 31+ messages in thread
From: Aditya Mahajan @ 2009-03-06  3:05 UTC (permalink / raw)
  To: mailing list for ConTeXt users

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1950 bytes --]

On Thu, 5 Mar 2009, luigi scarso wrote:

> On Thu, Mar 5, 2009 at 12:09 PM, Wolfgang Schuster
> <schuster.wolfgang@googlemail.com> wrote:
>>
>> Am 05.03.2009 um 01:17 schrieb luigi scarso:
>>
>>> \starttext
>>> %%% TeX version
>>> \bTABLE
>>> \dorecurse{5}
>>> {\bTR\expandafter \bTD \recurselevel. \eTD\expandafter
>>>        \bTD \recurselevel  \eTD\eTR}
>>> \eTABLE
>>>
>>> \dorecurse{2}
>>> {\recurselevel. \recurselevel\crlf}
>>
>> And you think it's a good idea to use \expandafter in your document?
> TeX  version, not context ... :)
> btw
> \expandafer is not so bad, if used moderatly .
>
>>
>> \expanded is the tool for users to get this result without knowledge
>> about TeX internals and expansion, this is from core-ntb:
>>
>> % permits \expanded{\bTD ... \eTD}
>>
>> \unexpanded\def\eTR{}
>> \unexpanded\def\eTD{}
>> \unexpanded\def\eTH{}
>> \unexpanded\def\eTN{}
> yes, of course one need to know about \expandafter... so is not so different .
> But it's context style.
>
>>
>>> %%% luatex version
>>> \startluacode
>>>   tprint = function(s) tex.sprint(tex.ctxcatcodes,s) end
>>>   tprint('\\bTABLE')
>>>   for j = 1,5 do
>>>       tprint('\\bTR')
>>>       tprint('\\bTD' .. j .. '.' .. '\\eTD' .. '\\bTD' .. j .. '\\eTD')
>>>       tprint('\\eTR')
>>>   end
>>>   tprint('\\eTABLE')
>>> \stopluacode
>>> \stoptext
>>
>> Nice solution and real alternative for package writers to avoid \expandafter
>> and \expanded but nothing for a normal user, I should keep this in my mind.
> Are you sure ?
> What is a normal user ?
> As soon as you use \dorecurse , you become a programmer .
>
> And sooner or later, everyone become a programmer, because it's
> impossible to write a format that satisfied
> all your needs .

My summary of this thread:
http://randomdeterminism.wordpress.com/2009/03/05/tex-programming-the-past-the-present-and-the-future/

Aditya

[-- Attachment #2: Type: text/plain, Size: 487 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: \dorecurse and \recurselevel in Natural Tables
  2009-03-06  3:05         ` Aditya Mahajan
@ 2009-03-06  6:41           ` luigi scarso
  2009-03-06 10:47             ` Wolfgang Schuster
  2009-03-06 11:20           ` Willi Egger
                             ` (3 subsequent siblings)
  4 siblings, 1 reply; 31+ messages in thread
From: luigi scarso @ 2009-03-06  6:41 UTC (permalink / raw)
  To: mailing list for ConTeXt users

>
> My summary of this thread:
> http://randomdeterminism.wordpress.com/2009/03/05/tex-programming-the-past-the-present-and-the-future/
It's exactly what I think .

Thank you very much.


-- 
luigi
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: \dorecurse and \recurselevel in Natural Tables
  2009-03-06  6:41           ` luigi scarso
@ 2009-03-06 10:47             ` Wolfgang Schuster
  0 siblings, 0 replies; 31+ messages in thread
From: Wolfgang Schuster @ 2009-03-06 10:47 UTC (permalink / raw)
  To: mailing list for ConTeXt users


Am 06.03.2009 um 07:41 schrieb luigi scarso:

>>
>> My summary of this thread:
>> http://randomdeterminism.wordpress.com/2009/03/05/tex-programming-the-past-the-present-and-the-future/
> It's exactly what I think .
>
> Thank you very much.

Nice article, it fits perfectly in the programming section of the wiki.

Thank your for the summary.

Wolfgang

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: \dorecurse and \recurselevel in Natural Tables
  2009-03-06  3:05         ` Aditya Mahajan
  2009-03-06  6:41           ` luigi scarso
@ 2009-03-06 11:20           ` Willi Egger
  2009-03-06 13:01           ` Curious Learn
                             ` (2 subsequent siblings)
  4 siblings, 0 replies; 31+ messages in thread
From: Willi Egger @ 2009-03-06 11:20 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hi Aditya,

Happy luaTeXing. Great summary.

Willi

On Mar 6, 2009, at 4:05 AM, Aditya Mahajan wrote:

> On Thu, 5 Mar 2009, luigi scarso wrote:
>
>> On Thu, Mar 5, 2009 at 12:09 PM, Wolfgang Schuster
>> <schuster.wolfgang@googlemail.com> wrote:
>>>
>>> Am 05.03.2009 um 01:17 schrieb luigi scarso:
>>>
>>>> \starttext
>>>> %%% TeX version
>>>> \bTABLE
>>>> \dorecurse{5}
>>>> {\bTR\expandafter \bTD \recurselevel. \eTD\expandafter
>>>>        \bTD \recurselevel  \eTD\eTR}
>>>> \eTABLE
>>>>
>>>> \dorecurse{2}
>>>> {\recurselevel. \recurselevel\crlf}
>>>
>>> And you think it's a good idea to use \expandafter in your document?
>> TeX  version, not context ... :)
>> btw
>> \expandafer is not so bad, if used moderatly .
>>
>>>
>>> \expanded is the tool for users to get this result without knowledge
>>> about TeX internals and expansion, this is from core-ntb:
>>>
>>> % permits \expanded{\bTD ... \eTD}
>>>
>>> \unexpanded\def\eTR{}
>>> \unexpanded\def\eTD{}
>>> \unexpanded\def\eTH{}
>>> \unexpanded\def\eTN{}
>> yes, of course one need to know about \expandafter... so is not so  
>> different .
>> But it's context style.
>>
>>>
>>>> %%% luatex version
>>>> \startluacode
>>>>   tprint = function(s) tex.sprint(tex.ctxcatcodes,s) end
>>>>   tprint('\\bTABLE')
>>>>   for j = 1,5 do
>>>>       tprint('\\bTR')
>>>>       tprint('\\bTD' .. j .. '.' .. '\\eTD' .. '\\bTD' .. j .. '\ 
>>>> \eTD')
>>>>       tprint('\\eTR')
>>>>   end
>>>>   tprint('\\eTABLE')
>>>> \stopluacode
>>>> \stoptext
>>>
>>> Nice solution and real alternative for package writers to avoid  
>>> \expandafter
>>> and \expanded but nothing for a normal user, I should keep this  
>>> in my mind.
>> Are you sure ?
>> What is a normal user ?
>> As soon as you use \dorecurse , you become a programmer .
>>
>> And sooner or later, everyone become a programmer, because it's
>> impossible to write a format that satisfied
>> all your needs .
>
> My summary of this thread:
> http://randomdeterminism.wordpress.com/2009/03/05/tex-programming- 
> the-past-the-present-and-the-future/
>
> Aditya________________________________________________________________ 
> ___________________
> If your question is of interest to others as well, please add an  
> entry to the Wiki!
>
> maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ 
> ntg-context
> webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
> archive  : https://foundry.supelec.fr/projects/contextrev/
> wiki     : http://contextgarden.net
> ______________________________________________________________________ 
> _____________

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: \dorecurse and \recurselevel in Natural Tables
  2009-03-06  3:05         ` Aditya Mahajan
  2009-03-06  6:41           ` luigi scarso
  2009-03-06 11:20           ` Willi Egger
@ 2009-03-06 13:01           ` Curious Learn
  2009-03-06 13:32             ` Arthur Reutenauer
  2009-03-06 13:35             ` luigi scarso
  2009-03-06 14:49           ` Wolfgang Schuster
  2009-03-06 16:38           ` Aditya Mahajan
  4 siblings, 2 replies; 31+ messages in thread
From: Curious Learn @ 2009-03-06 13:01 UTC (permalink / raw)
  To: ntg-context

Aditya Mahajan <adityam <at> umich.edu> writes:

> My summary of this thread:
>
http://randomdeterminism.wordpress.com/2009/03/05/tex-programming-the-past-the-present-and-the-future/
> 
> Aditya

I like the Luatex code of Luigi. Though it is longer than what Wolfgang
suggested (and in this case, I am using Wolfgang's solution now that I know
about it), the luatex code seems to be the kind of programming that I am more
comfortable with. In fact, in Latex when I was trying to achieve this, I used
the python.sty package to code this in Python.

To be able to do this using Lua (Luatex), do I need to learn the Lua programming
language. Do I pick up any beginners book on Lua? Any recommendations based on
experience of those who use Luatex here.

For example, one of the lines in the code is 

 tprint = function(s) tex.sprint(tex.ctxcatcodes,s) end 

Is this Lua or LuaTex?

Thanks. 

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: \dorecurse and \recurselevel in Natural Tables
  2009-03-06 13:01           ` Curious Learn
@ 2009-03-06 13:32             ` Arthur Reutenauer
  2009-03-06 16:15               ` Curious Learn
  2009-03-06 13:35             ` luigi scarso
  1 sibling, 1 reply; 31+ messages in thread
From: Arthur Reutenauer @ 2009-03-06 13:32 UTC (permalink / raw)
  To: Mailing list for ConTeXt users

>           Do I pick up any beginners book on Lua?

  There really is only one beginners book on Lua :-)  _Programming in
Lua_, by Roberto Ierusalimschy, the Lua author.  There are a few other
books, mostly about "Lua and games", because Lua has become quite
popular in the gamers' community, but Roberto's book is really excellent
and makes a good tutorial.

> For example, one of the lines in the code is 
> 
>  tprint = function(s) tex.sprint(tex.ctxcatcodes,s) end 
> 
> Is this Lua or LuaTex?

  The question does not really makes sense if you put it that way.  This
line of code is pure Lua, it is completely syntactically correct; but
you can't use as it a standalone Lua script, because it uses functions
that only LuaTeX and ConTeXt define (think of it as the action of
"import" in Python, except that here it's not available as a stand-alone
library call; it's built into LuaTeX).

  Hence, if you want to become proficient in Lua programming in ConTeXt,
you need to learn:

  * The Lua programming language, with its core libraries (covered in
    the aforementioned book).

  * The Lua libraries that LuaTeX adds to Lua, documented in the LuaTeX
    manual.

  * The Lua libraries that ConTeXt adds to LuaTeX.

  The above line of code is really a mixture of the three, but in any
case, the ground stone is always Lua.

	Arthur
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: \dorecurse and \recurselevel in Natural Tables
  2009-03-06 13:01           ` Curious Learn
  2009-03-06 13:32             ` Arthur Reutenauer
@ 2009-03-06 13:35             ` luigi scarso
  1 sibling, 0 replies; 31+ messages in thread
From: luigi scarso @ 2009-03-06 13:35 UTC (permalink / raw)
  To: mailing list for ConTeXt users

> I like the Luatex code of Luigi. Though it is longer than what Wolfgang
> suggested (and in this case, I am using Wolfgang's solution now that I know
> about it), the luatex code seems to be the kind of programming that I am more
> comfortable with. In fact, in Latex when I was trying to achieve this, I used
> the python.sty package to code this in Python.
The optimal  solution is that one of Wolfgang that uses \expanded .
The others are less than optimal.

> To be able to do this using Lua (Luatex), do I need to learn the Lua programming
> language. Do I pick up any beginners book on Lua? Any recommendations based on
> experience of those who use Luatex here.
Programming in Lua ,
see www.lua.org


>
> For example, one of the lines in the code is
>
>  tprint = function(s) tex.sprint(tex.ctxcatcodes,s) end
>
> Is this Lua or LuaTex?
luatex


-- 
luigi
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: \dorecurse and \recurselevel in Natural Tables
  2009-03-06  3:05         ` Aditya Mahajan
                             ` (2 preceding siblings ...)
  2009-03-06 13:01           ` Curious Learn
@ 2009-03-06 14:49           ` Wolfgang Schuster
  2009-03-06 16:33             ` Aditya Mahajan
  2009-03-06 16:38           ` Aditya Mahajan
  4 siblings, 1 reply; 31+ messages in thread
From: Wolfgang Schuster @ 2009-03-06 14:49 UTC (permalink / raw)
  To: mailing list for ConTeXt users


Am 06.03.2009 um 04:05 schrieb Aditya Mahajan:

> My summary of this thread:
> http://randomdeterminism.wordpress.com/2009/03/05/tex-programming-the-past-the-present-and-the-future/

Nice article but I have a few corrections for you.


Table setup:

To achieve horizontal and vertical centered content in the table cell
you need 'align={middle,lohi}'.


Pure table code:

You forgot the \bTR and \eTR before and after each row.


Expandafter solution:

You don't need as many \expandafter as you did in your example,
one before \bTD in each loop is enough.

\bTABLE
  \bTR
   \bTD $(+)$ \eTD
   \dorecurse{6}
    {\expandafter \bTD \recurselevel \eTD}
   \eTR
\dorecurse{6}
  {\bTR
      \edef\firstrecurselevel{\recurselevel}
      \expandafter\bTD \recurselevel \eTD
   \dorecurse{6}
     {\expandafter
      \bTD
       \the\numexpr\firstrecurselevel+\recurselevel\relax
      \eTD}
   \eTR}
\eTABLE


\for loop:

If you really want to show this loop you also the correct
commands to access the counters. #1 did also work but only
because the command is wrapped around \dostepwiserecurse.

\bTABLE
   \bTR
     \bTD $(+)$ \eTD
     \for \y=1 \to 6 \step 1 \do
       {\bTD \y \eTD}
   \eTR
   \for \x=1 \to 6 \step 1 \do
   {\bTR
      \bTD \x \eTD
     \for \y=1 \to 6 \step 1 \do
     {\bTD \the\numexpr\x+\y \eTD}
   \eTR}
\eTABLE


Thank you for the article and I'm looking forward for the next.

Best regards,
Wolfgang

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: \dorecurse and \recurselevel in Natural Tables
  2009-03-06 13:32             ` Arthur Reutenauer
@ 2009-03-06 16:15               ` Curious Learn
  0 siblings, 0 replies; 31+ messages in thread
From: Curious Learn @ 2009-03-06 16:15 UTC (permalink / raw)
  To: ntg-context



Arthur and Luigi, thanks for your responses. Arthur, your response makes it very
clear, what I need to do. I will start with the book you recommend.



___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: \dorecurse and \recurselevel in Natural Tables
  2009-03-06 14:49           ` Wolfgang Schuster
@ 2009-03-06 16:33             ` Aditya Mahajan
  2009-03-06 17:07               ` Wolfgang Schuster
  0 siblings, 1 reply; 31+ messages in thread
From: Aditya Mahajan @ 2009-03-06 16:33 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On Fri, 6 Mar 2009, Wolfgang Schuster wrote:

>
> Am 06.03.2009 um 04:05 schrieb Aditya Mahajan:
>
>> My summary of this thread:
>> http://randomdeterminism.wordpress.com/2009/03/05/tex-programming-the-past-the-present-and-the-future/
>
> Nice article but I have a few corrections for you.
>
>
> Table setup:
>
> To achieve horizontal and vertical centered content in the table cell
> you need 'align={middle,lohi}'.

Hmm... align={middle,middle} also works. I haven't checked the code to see 
why.

>
> Pure table code:
>
> You forgot the \bTR and \eTR before and after each row.

Thanks.

>
> Expandafter solution:
>
> You don't need as many \expandafter as you did in your example,
> one before \bTD in each loop is enough.
>
> \bTABLE
> \bTR
>  \bTD $(+)$ \eTD
>  \dorecurse{6}
>   {\expandafter \bTD \recurselevel \eTD}
>  \eTR
> \dorecurse{6}
> {\bTR
>     \edef\firstrecurselevel{\recurselevel}
>     \expandafter\bTD \recurselevel \eTD
>  \dorecurse{6}
>    {\expandafter
>     \bTD
>      \the\numexpr\firstrecurselevel+\recurselevel\relax
>     \eTD}
>  \eTR}
> \eTABLE

Ah. I was experimenting without the \the\numexpr (replacing both by 
\relax) so that I could see the output. I did not realize that \numexpr 
expands its arguments anyways.
>
> \for loop:
>
> If you really want to show this loop you also the correct
> commands to access the counters. #1 did also work but only
> because the command is wrapped around \dostepwiserecurse.
>
> \bTABLE
>  \bTR
>    \bTD $(+)$ \eTD
>    \for \y=1 \to 6 \step 1 \do
>      {\bTD \y \eTD}
>  \eTR
>  \for \x=1 \to 6 \step 1 \do
>  {\bTR
>     \bTD \x \eTD
>    \for \y=1 \to 6 \step 1 \do
>    {\bTD \the\numexpr\x+\y \eTD}
>  \eTR}
> \eTABLE

This does not work, for the same reason that the \dorecurse solution does 
not work. You need to exapnad \x and \y in the first row and first column.

> Thank you for the article and I'm looking forward for the next.

Thanks for the feedback.

Aditya
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: \dorecurse and \recurselevel in Natural Tables
  2009-03-06  3:05         ` Aditya Mahajan
                             ` (3 preceding siblings ...)
  2009-03-06 14:49           ` Wolfgang Schuster
@ 2009-03-06 16:38           ` Aditya Mahajan
  4 siblings, 0 replies; 31+ messages in thread
From: Aditya Mahajan @ 2009-03-06 16:38 UTC (permalink / raw)
  To: mailing list for ConTeXt users

[-- Attachment #1: Type: TEXT/PLAIN, Size: 3175 bytes --]

On Thu, 5 Mar 2009, Aditya Mahajan wrote:

> On Thu, 5 Mar 2009, luigi scarso wrote:
>
>> On Thu, Mar 5, 2009 at 12:09 PM, Wolfgang Schuster
>> <schuster.wolfgang@googlemail.com> wrote:
>>> 
>>> Am 05.03.2009 um 01:17 schrieb luigi scarso:
>>> 
>>>> \starttext
>>>> %%% TeX version
>>>> \bTABLE
>>>> \dorecurse{5}
>>>> {\bTR\expandafter \bTD \recurselevel. \eTD\expandafter
>>>>        \bTD \recurselevel  \eTD\eTR}
>>>> \eTABLE
>>>> 
>>>> \dorecurse{2}
>>>> {\recurselevel. \recurselevel\crlf}
>>> 
>>> And you think it's a good idea to use \expandafter in your document?
>> TeX  version, not context ... :)
>> btw
>> \expandafer is not so bad, if used moderatly .
>> 
>>> 
>>> \expanded is the tool for users to get this result without knowledge
>>> about TeX internals and expansion, this is from core-ntb:
>>> 
>>> % permits \expanded{\bTD ... \eTD}
>>> 
>>> \unexpanded\def\eTR{}
>>> \unexpanded\def\eTD{}
>>> \unexpanded\def\eTH{}
>>> \unexpanded\def\eTN{}
>> yes, of course one need to know about \expandafter... so is not so 
>> different .
>> But it's context style.
>> 
>>> 
>>>> %%% luatex version
>>>> \startluacode
>>>>   tprint = function(s) tex.sprint(tex.ctxcatcodes,s) end
>>>>   tprint('\\bTABLE')
>>>>   for j = 1,5 do
>>>>       tprint('\\bTR')
>>>>       tprint('\\bTD' .. j .. '.' .. '\\eTD' .. '\\bTD' .. j .. '\\eTD')
>>>>       tprint('\\eTR')
>>>>   end
>>>>   tprint('\\eTABLE')
>>>> \stopluacode
>>>> \stoptext
>>> 
>>> Nice solution and real alternative for package writers to avoid 
>>> \expandafter
>>> and \expanded but nothing for a normal user, I should keep this in my 
>>> mind.
>> Are you sure ?
>> What is a normal user ?
>> As soon as you use \dorecurse , you become a programmer .
>> 
>> And sooner or later, everyone become a programmer, because it's
>> impossible to write a format that satisfied
>> all your needs .
>
> My summary of this thread:
> http://randomdeterminism.wordpress.com/2009/03/05/tex-programming-the-past-the-present-and-the-future/

For fun: Using metapost

\setupcolors[state=start]
\setupTABLE[each][each][width=2em,height=2em,align={middle,middle}]
\setupTABLE[r][1][background=color,backgroundcolor=gray]
\setupTABLE[c][1][background=color,backgroundcolor=gray]

\let\normalbTABLE\bTABLE
\let\normaleTABLE\eTABLE

\unexpanded\def\bTABLE{\normalbTABLE}
\unexpanded\def\eTABLE{\normaleTABLE}

\unexpanded\def\dobTR{\dodoubleempty\parseTR}
\unexpanded\def\dobTD{\dodoubleempty\parseTD}
\unexpanded\def\dobTH{\dodoubleempty\parseTH}
\unexpanded\def\dobTN{\dodoubleempty\parseTN}

\let\bTR\dobTR
\let\bTD\dobTD
\let\bTH\dobTH
\let\bTN\dobTN

\starttext

\startMPcode
   string table ;
   table = "\bTABLE \bTR \bTD $(+)$ \eTD" &
     for y = 1 upto 6 :
       "\bTD " & decimal y & "\eTD " &
     endfor
     "\eTR " &
     for x = 1 upto 6 :
       "\bTR \bTD " & decimal x & "\eTD " &
       for y = 1 upto 6 :
        "\bTD " & decimal (x+y) & "\eTD " &
       endfor
       "\eTR" &
     endfor
     "\eTABLE" ;
   label(textext(table), origin) ;
\stopMPcode

\stoptext

Aditya

[-- Attachment #2: Type: text/plain, Size: 487 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: \dorecurse and \recurselevel in Natural Tables
  2009-03-06 16:33             ` Aditya Mahajan
@ 2009-03-06 17:07               ` Wolfgang Schuster
  0 siblings, 0 replies; 31+ messages in thread
From: Wolfgang Schuster @ 2009-03-06 17:07 UTC (permalink / raw)
  To: mailing list for ConTeXt users


Am 06.03.2009 um 17:33 schrieb Aditya Mahajan:

>> Table setup:
>>
>> To achieve horizontal and vertical centered content in the table cell
>> you need 'align={middle,lohi}'.
>
> Hmm... align={middle,middle} also works. I haven't checked the code  
> to see why.

I hadn't known this before but it's feature of framed, good to know.

>> Expandafter solution:
>
> Ah. I was experimenting without the \the\numexpr (replacing both by  
> \relax) so that I could see the output. I did not realize that  
> \numexpr expands its arguments anyways.

The first recurselevel was expanded with your \edef and the second
with the \expandafter before \bTD.

>> \for loop:
>
> This does not work, for the same reason that the \dorecurse solution  
> does not work. You need to exapnad \x and \y in the first row and  
> first column.

I should next time check the output. Sure, the same rules as \dorecurse
apply to the \for loop.

Wolfgang

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 31+ messages in thread

end of thread, other threads:[~2009-03-06 17:07 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-04 19:35 \dorecurse and \recurselevel in Natural Tables Curious Learn
2009-03-04 19:53 ` luigi scarso
2009-03-04 20:04   ` luigi scarso
2009-03-05  0:17   ` luigi scarso
2009-03-05 11:09     ` Wolfgang Schuster
2009-03-05 11:27       ` luigi scarso
2009-03-05 12:00         ` Wolfgang Schuster
2009-03-05 13:23           ` luigi scarso
2009-03-05 13:52             ` Wolfgang Schuster
2009-03-05 14:23               ` luigi scarso
2009-03-05 14:53                 ` Wolfgang Schuster
2009-03-05 15:08                   ` luigi scarso
2009-03-06  3:05         ` Aditya Mahajan
2009-03-06  6:41           ` luigi scarso
2009-03-06 10:47             ` Wolfgang Schuster
2009-03-06 11:20           ` Willi Egger
2009-03-06 13:01           ` Curious Learn
2009-03-06 13:32             ` Arthur Reutenauer
2009-03-06 16:15               ` Curious Learn
2009-03-06 13:35             ` luigi scarso
2009-03-06 14:49           ` Wolfgang Schuster
2009-03-06 16:33             ` Aditya Mahajan
2009-03-06 17:07               ` Wolfgang Schuster
2009-03-06 16:38           ` Aditya Mahajan
2009-03-04 20:35 ` Wolfgang Schuster
2009-03-04 20:57   ` Curious Learn
2009-03-04 21:11     ` Wolfgang Schuster
2009-03-04 21:43       ` Aditya Mahajan
2009-03-04 21:51         ` Wolfgang Schuster
2009-03-04 22:17       ` Curious Learn
2009-03-04 22:35         ` Wolfgang Schuster

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).