Re: [NTG-context] \dorecurse and \recurselevel in Natural Tables

2009-03-06 Thread Wolfgang Schuster


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
___


Re: [NTG-context] \dorecurse and \recurselevel in Natural Tables

2009-03-06 Thread Willi Egger

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.wolfg...@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
___


Re: [NTG-context] \dorecurse and \recurselevel in Natural Tables

2009-03-06 Thread Curious Learn
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
___


Re: [NTG-context] \dorecurse and \recurselevel in Natural Tables

2009-03-06 Thread Arthur Reutenauer
   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
___


Re: [NTG-context] \dorecurse and \recurselevel in Natural Tables

2009-03-06 Thread luigi scarso
 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
___


Re: [NTG-context] \dorecurse and \recurselevel in Natural Tables

2009-03-06 Thread Wolfgang Schuster


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
___


Re: [NTG-context] \dorecurse and \recurselevel in Natural Tables

2009-03-06 Thread Curious Learn


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
___


Re: [NTG-context] \dorecurse and \recurselevel in Natural Tables

2009-03-06 Thread Aditya Mahajan

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
___


Re: [NTG-context] \dorecurse and \recurselevel in Natural Tables

2009-03-06 Thread Aditya Mahajan

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.wolfg...@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___
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
___


Re: [NTG-context] \dorecurse and \recurselevel in Natural Tables

2009-03-06 Thread Wolfgang Schuster


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
___


Re: [NTG-context] \dorecurse and \recurselevel in Natural Tables

2009-03-05 Thread luigi scarso
On Wed, Mar 4, 2009 at 8:53 PM, luigi scarso luigi.sca...@gmail.com wrote:
 On Wed, Mar 4, 2009 at 8:35 PM, Curious Learn curiousle...@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
___


Re: [NTG-context] \dorecurse and \recurselevel in Natural Tables

2009-03-05 Thread Wolfgang Schuster


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
___


Re: [NTG-context] \dorecurse and \recurselevel in Natural Tables

2009-03-05 Thread luigi scarso
On Thu, Mar 5, 2009 at 12:09 PM, Wolfgang Schuster
schuster.wolfg...@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
___


Re: [NTG-context] \dorecurse and \recurselevel in Natural Tables

2009-03-05 Thread Wolfgang Schuster


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
___


Re: [NTG-context] \dorecurse and \recurselevel in Natural Tables

2009-03-05 Thread luigi scarso
 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
___


Re: [NTG-context] \dorecurse and \recurselevel in Natural Tables

2009-03-05 Thread Wolfgang Schuster


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
___


Re: [NTG-context] \dorecurse and \recurselevel in Natural Tables

2009-03-05 Thread luigi scarso
On Thu, Mar 5, 2009 at 2:52 PM, Wolfgang Schuster
schuster.wolfg...@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
___


Re: [NTG-context] \dorecurse and \recurselevel in Natural Tables

2009-03-05 Thread Wolfgang Schuster


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
___


Re: [NTG-context] \dorecurse and \recurselevel in Natural Tables

2009-03-05 Thread luigi scarso
On Thu, Mar 5, 2009 at 3:53 PM, Wolfgang Schuster
schuster.wolfg...@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
___


Re: [NTG-context] \dorecurse and \recurselevel in Natural Tables

2009-03-05 Thread Aditya Mahajan

On Thu, 5 Mar 2009, luigi scarso wrote:


On Thu, Mar 5, 2009 at 12:09 PM, Wolfgang Schuster
schuster.wolfg...@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
___


Re: [NTG-context] \dorecurse and \recurselevel in Natural Tables

2009-03-05 Thread 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.


-- 
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
___


[NTG-context] \dorecurse and \recurselevel in Natural Tables

2009-03-04 Thread 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 

\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
___


Re: [NTG-context] \dorecurse and \recurselevel in Natural Tables

2009-03-04 Thread luigi scarso
On Wed, Mar 4, 2009 at 8:35 PM, Curious Learn curiousle...@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
___


Re: [NTG-context] \dorecurse and \recurselevel in Natural Tables

2009-03-04 Thread luigi scarso
On Wed, Mar 4, 2009 at 8:53 PM, luigi scarso luigi.sca...@gmail.com wrote:
 On Wed, Mar 4, 2009 at 8:35 PM, Curious Learn curiousle...@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
___


Re: [NTG-context] \dorecurse and \recurselevel in Natural Tables

2009-03-04 Thread Wolfgang Schuster


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
___


Re: [NTG-context] \dorecurse and \recurselevel in Natural Tables

2009-03-04 Thread Curious Learn
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
___


Re: [NTG-context] \dorecurse and \recurselevel in Natural Tables

2009-03-04 Thread Wolfgang Schuster


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
___


Re: [NTG-context] \dorecurse and \recurselevel in Natural Tables

2009-03-04 Thread Aditya Mahajan

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
___


Re: [NTG-context] \dorecurse and \recurselevel in Natural Tables

2009-03-04 Thread Wolfgang Schuster


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
___


Re: [NTG-context] \dorecurse and \recurselevel in Natural Tables

2009-03-04 Thread Curious Learn

 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
___


Re: [NTG-context] \dorecurse and \recurselevel in Natural Tables

2009-03-04 Thread Wolfgang Schuster


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
___