Hi all,

I need to define numerical coefficients (essentially at random) and then use 
them with commands, say like \CoeffAlpha, \CoeffBeta, and so on.
More precisely, how can I define the command \RandomCoeff, so that 
\RandomCoeff{Beta}{1}{10} yields a command named \CoeffBeta, which is a random 
number chosen between 1 and 10?

I tried to use the following approach, but could not make it work:

%%% begin random-coeff.tex
\setuprandomize[2012] % set a seed 

\ctxlua{CoeffAlpha = math.random(1,10) ;}
\def\CoeffAlpha{\ctxlua{tex.print(CoeffAlpha)}}

%%%%%
\define[3]\RandomCoeff{%
        \ctxlua{a = math.random(#2,#3)}
%       \csname{Coeff#1}\endcsname{\ctxlua{tex.print(a)}} %% this line does not 
work as expected...
        }

\starttext
\CoeffAlpha

\RandomCoeff{Beta}{1}{10}

\ctxlua{tex.print(a)}

%\CoeffBeta

\stoptext
%%% end random-coeff.tex

Thanks in advance for any suggestion or hint.
Best regards: OK

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

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

Reply via email to