Changes

Jump to navigation Jump to search
20 bytes added ,  12:35, 2 November 2007
= Luatex examples =
Examples from <tt>Vyatcheslav Yatskovsky <yatskovsky@at gmail.com> </tt>
*Say you 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 should remain the same, only figures have to be changed through papers, only numbers had.Instead of filling in numbers manually, you can wrote write simple lua Lua scripts to generate random numbers right values withing given range just inside the document:
<pre>
% question involving random decimal numberConvert \ctxlua{n=math.random(30,60) ; tex.print(n) ;}\low{10} into Bin.
% question involving random binary number
Convert
\startluacode
end
\stopluacode\low{2} into Hex.
</pre>
*% a pair of random hexadecimalsPerform logical AND, OR and XOR under the following pair of hexadecimal numbers:<pre>
\startluacode
n = math.random(10,255)
tex.print(string.format("%X, %X", n, m))
\stopluacode
</pre>*% random wordEncode your Name and Surname full name as a<pre>
\startluacode
a = {'null-terminated', 'dollar-terminated', 'Pascalshortstring'}
tex.print( string.format('%s string.', a[math.random(1,3)]) );
\stopluacode
128

edits

Navigation menu