Hello all,
Let me share my luatex "success story". I teach computer science, and current topics I deliver are Numbering Systems and Data Representation. Yesterday, I needed to prepare about twenty test papers with 10 questions per a paper. Examples: "1. convert Dec 36 into Hex", "2. convert Bin 10010101 into Dec", etc. The wording of every question has not to be changed through papers, only numbers had.
Instead of filling in numbers manually, I took more intelligent approach and (with Hans' help) wrote simple lua scripts to generate random numbers right inside my document:
% question involving random decimal number
Convert \ctxlua{n=math.random(30,60) ; tex.print(n) ;}\low{10} into Bin.
% question involving random binary number
Convert
\startluacode
for c = 1, 16 do
n = math.random(0,1)
tex.sprint(n)
end
\stopluacode\low{2} into Hex.
and so on... I specified the lower and upper limits as two arguments of random function, and that was very easy indeed.
Then I copied my finished test text and pasted it many-many times. (It was probably not very wise approach, but I'm not familiar with looping TeX commands at the moment.) Luatex did the rest of the job perfectly, and in minute I had test papers with identical questions but all different figures! I only had to cut papers apart and hand out to my students.
Best regards,
Vyatcheslav Yatskovsky