summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/pst-math/pst-math.sty
blob: 0c0f1aef4075c53e3ae37daf7267d7b58c6f0646 (plain)
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
% $Id: pst-math.sty 864 2018-12-15 21:15:11Z 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/16 v 0.65 package wrapper for PSTricks pst-math.tex]
\RequirePackage{pst-calculate}
\RequirePackage{ifluatex}
\RequirePackage{xstring}
\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.65,  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\R@Control{}%
  \multido{\iA=1+1}{\theRandom@No@max}{\xdef\R@Control{0\R@Control}}%
}

\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
  }%
}
%
\def\makeRandomNumberList{%
  \edef\@Number{\pscalculate{randint(\theRandom@Left,\theRandom@Right)}}% Zufallszahl
  \add@Number{\@Number}}

\def\add@Number#1{%
  \def\R@Left{}\def\R@Right{}\def\R@Value{}%
  \StrChar{\R@Control}{#1}[\R@Value]
  \ifnum\R@Value=0 
    \stepcounter{Rand@No}%
    \ifnum\theRand@No=1\relax
      \gdef\RandomNumbers{#1}%
    \else
      \xdef\RandomNumbers{\RandomNumbers,#1}%
    \fi
    \StrLeft{\R@Control}{\the\numexpr#1-1}[\R@Left]%
    \StrRight{\R@Control}{\the\numexpr\theRandom@No@max-#1}[\R@Right]%
    \xdef\R@Control{\R@Left1\R@Right}%
  \fi
  \ifnum\theRand@No=\theRandom@No@max
    \def\next{}%
  \else
    \def\next{\makeRandomNumberList}%
  \fi
  \next
}
\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