1
2
3
4
5
6
7
8
9
10
11
12
13
14\writestatus{loading}{ConTeXt Support Macros Random Number Generation}
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29\registerctxluafile{suppran}{}
30
31\unprotect
32
33\protected\def\getrandomcount #1#2#3{#1=\clf_getrandomnumber\numexpr#2\relax\numexpr#3\relax\relax}
34\protected\def\getrandomdimen #1#2#3{#1=\clf_getrandomdimen\dimexpr#2\relax\dimexpr#3\relax\scaledpoint\relax}
35\protected\def\getrandomnumber#1#2#3{\edef#1{\clf_getrandomnumber\numexpr#2\relax\numexpr#3\relax}}
36\protected\def\getrandomfloat #1#2#3{\edef#1{\clf_getrandomfloat\dimexpr#2\relax\dimexpr#3\relax}}
37\protected\def\setrandomseed #1{\clf_setrandomseed\numexpr#1\relax}
38\protected\def\getrandomseed #1{\edef#1{\clf_getrandomseed}}
39\protected\def\newrandomseed {\clf_getrandomseed}
40
41
42
43
44\let\freezerandomseed \pushrandomseed
45\let\defrostrandomseed\poprandomseed
46
47\setnewconstant \mpscaledmax 4095
48
49\def\randomnumber #1#2{\clf_getrandomnumber\numexpr#1\relax\numexpr#2\relax}
50\def\mprandomnumber {\clf_getrandomnumber\zerocount\mpscaledmax}
51
52\protect \endinput
53 |