On 8-6-2011 6:52, Otared Kavian wrote:
Hi all,
Assuming that we have a set of words or expressions, say
{Maths, Physics, Algebra, Analysis, Chemistry, Geometry, Wave equation,
Schrödinger equation}
is it possible to write a lua function, named for instance
randomselectword
which returns one of the words or expressions selected at random in the above
set?
Indeed this is intended to be used in a TeX file processed with mkiv.
something
function document.r(str)
local set = utilities.parsers.settings_to_array(str)
context(set[math.round(math.random(1,#set))])
end
\ctxlua{document.r("math physics")}
(untested)
-----------------------------------------------------------------
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 : ntg-context@ntg.nl / 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
___________________________________________________________________________________