Changes

Jump to navigation Jump to search
1,063 bytes added ,  07:09, 2 November 2007
Examples from <tt>Vyatcheslav Yatskovsky <yatskovsky@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 to be changed through papers, only numbers had.Instead of filling in numbers manually, you can wrote simple lua scripts to generate random numbers right inside the document:
<pre>
% 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.
</pre>
 
*Perform logical AND, OR and XOR under the following pair of hexadecimal numbers:
<pre>
\startluacode
n = math.random(10,255)
m = math.random(10,255)
tex.print(string.format("%X, %X", n, m))
\stopluacode
</pre>
*Encode your Name and Surname as a
<pre>
\startluacode
a = {'null-terminated', 'dollar-terminated', 'Pascal'}
tex.print( string.format('%s string.', a[math.random(1,3)]) );
\stopluacode
</pre>
= Luatex hosts python =
Anonymous user

Navigation menu