1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
% $Id: pst-math.sty 859 2018-12-13 15:31:03Z herbert $
%%
%% This is file `pst-math.sty'.
%%
%% IMPORTANT NOTICE:
%%
%% pst-math Copyright (C) 2019- Herbert Voss <hvoss@tug.org>
%%
%% This package may be distributed under the terms of the LaTeX Project
%% Public License, as described in lppl.txt in the base LaTeX distribution.
%% Either version 1.0 or, at your option, any later version.
%%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{pst-math}[2018/12/13 v 0.64package wrapper for PSTricks pst-math.tex]
\RequirePackage{pst-calculate}
\input pst-math.tex
\ProvidesFile{pst-math.tex}
[\filedate\space v\fileversion\space `PST-math' (hv)]
\IfFileExists{pst-math.pro}{\ProvidesFile{pst-math.pro}%
[2018/12/13 v. 0.64, PostScript prologue file (hv)]
\@addtofilelist{pst-math.pro}}{}%
\newcounter{Rand@No}\newcounter{Random@Left}\newcounter{Random@Right}\newcounter{Random@No@max}%
\setcounter{Rand@No}{0}\setcounter{Random@Left}{1}\setcounter{Random@Right}{1000}%
\def\defineRandIntervall(#1,#2)#3{%
\setcounter{Random@Left}{#1}%
\setcounter{Random@Right}{#2}%
\setcounter{Random@No@max}{#3}%
\setcounter{Rand@No}{0}%
\def\RandomNumbers{}%
}
\def\RandomNumbers{}%\pscalculate{randint(\theRandom@Left,\theRandom@Right)}}
\def\makeSimpleRandomNumberList{%
\def\RandomNumbers{}%
\psforeach{\iA}{1,2,..,\theRandom@No@max}{%
\edef\@Number{\pscalculate{randint(\theRandom@Left,\theRandom@Right)}}% Zufallszahl
\ifnum\iA=1
\xdef\RandomNumbers{\@Number}%
\else
\xdef\RandomNumbers{\RandomNumbers,\@Number}%
\fi
% \typeout{\RandomNumbers}%
}%
}
%
\def\makeRandomNumberList{%
\edef\@Number{\pscalculate{randint(\theRandom@Left,\theRandom@Right)}}% Zufallszahl
\ifnum\theRand@No=\z@
\xdef\RandomNumbers{\@Number}%
\stepcounter{Rand@No}%
\xdef\@Number{\pscalculate{randint(\theRandom@Left,\theRandom@Right)}}% Zufallszahl
\fi
\add@Number{\@Number}\RandomNumbers!!}
\def\add@Number#1#2!!{\edef\x{\noexpand\add@Number@i#1;#2,,\relax}\x}
\def\add@Number@i#1;#2,#3,#4\relax{%
\ifx\relax#2\relax % we found new number
\xdef\RandomNumbers{\RandomNumbers,#1}%
\stepcounter{Rand@No}%
\ifnum\theRand@No>\theRandom@No@max
\def\next{}% Neue Zahl?
\else
\def\next{\makeRandomNumberList}
\fi%
\else
\ifnum#1=#2 % no new number
\def\next{\makeRandomNumberList}%
\else
\ifx\relax#3\relax
\def\next{\add@Number@i#1;,,\relax}%
\else %
\def\next{\add@Number@i#1;#3,#4\relax}%
\fi
\fi
\fi
\ifnum\theRand@No<\theRandom@No@max \next \fi
}
\def\getNumberFromList#1{%
\global\count0 = 1
\edef\x{\noexpand\get@Index#1;\RandomNumbers}\x,,\relax}
\def\get@Index#1;#2,#3,#4\relax{%
\ifnum\the\count0=#1
\def\next{#2}%
\else
\global\advance\count0 by 1
\def\next{\get@Index#1;#3,#4\relax}%
\fi
\next
}
\endinput
|