On 8-6-2011 7:00, Mathieu Dupont wrote:


This following code works, except that the first random is always the same 
(Analysis) for some reason.
Anyone knows why ?
\enableregime[il1]\starttext\startluacode       userdata = userdata or {}       math.randomseed( os.time() )    function userdata.random(...)           
context(arg[math.random(1, #arg)])      end\stopluacode\def\CHOOSERANDOM#1{\ctxlua{userdata.random(#1)}}\dorecurse{10}{\CHOOSERANDOM{"Maths", 
"Physics", "Algebra", "Analysis", "Chemistry", "Geometry", "Wave equation", "Schrödinger 
equation"}\par}\stoptext

Because context remembers the seed (is reported in the log). Delete the tuc file and you will get another value. We could get oscillation otherwise.


-----------------------------------------------------------------
                                          Hans Hagen | PRAGMA ADE
              Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
    tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
                                             | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
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