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