diff options
Diffstat (limited to 'Master')
-rw-r--r-- | Master/texmf-dist/doc/lualatex/luarandom/Changes | 2 | ||||
-rw-r--r-- | Master/texmf-dist/doc/lualatex/luarandom/README | 2 | ||||
-rw-r--r-- | Master/texmf-dist/doc/lualatex/luarandom/luarandom-doc.pdf | bin | 49787 -> 70042 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/lualatex/luarandom/luarandom-doc.tex | 39 | ||||
-rw-r--r-- | Master/texmf-dist/tex/lualatex/luarandom/luarandom.sty | 37 |
5 files changed, 56 insertions, 24 deletions
diff --git a/Master/texmf-dist/doc/lualatex/luarandom/Changes b/Master/texmf-dist/doc/lualatex/luarandom/Changes index 29cf20e0232..ac867c21309 100644 --- a/Master/texmf-dist/doc/lualatex/luarandom/Changes +++ b/Master/texmf-dist/doc/lualatex/luarandom/Changes @@ -1,4 +1,6 @@ ..... luarandom.sty +0.02 2023-11-13 - fix for endless loop, + - added optional argument for special seed number 0.01 2018-12-15 first CTAN version (hv) diff --git a/Master/texmf-dist/doc/lualatex/luarandom/README b/Master/texmf-dist/doc/lualatex/luarandom/README index f51f725e010..a7abc866116 100644 --- a/Master/texmf-dist/doc/lualatex/luarandom/README +++ b/Master/texmf-dist/doc/lualatex/luarandom/README @@ -9,4 +9,4 @@ The macros for random numbers can only be used with LuaLaTeX! hvoss@tug.org -%% $Id: README 862 2018-12-15 16:25:55Z herbert $ +%% $Id: README 813 2023-11-13 19:33:29Z herbert $ diff --git a/Master/texmf-dist/doc/lualatex/luarandom/luarandom-doc.pdf b/Master/texmf-dist/doc/lualatex/luarandom/luarandom-doc.pdf Binary files differindex 9f137411ad0..04287903aaa 100644 --- a/Master/texmf-dist/doc/lualatex/luarandom/luarandom-doc.pdf +++ b/Master/texmf-dist/doc/lualatex/luarandom/luarandom-doc.pdf diff --git a/Master/texmf-dist/doc/lualatex/luarandom/luarandom-doc.tex b/Master/texmf-dist/doc/lualatex/luarandom/luarandom-doc.tex index 6c17c1647d3..069d239d074 100644 --- a/Master/texmf-dist/doc/lualatex/luarandom/luarandom-doc.tex +++ b/Master/texmf-dist/doc/lualatex/luarandom/luarandom-doc.tex @@ -1,9 +1,8 @@ -%% $Id: luarandom-doc.tex 862 2018-12-15 16:25:55Z herbert $ +%% $Id: luarandom-doc.tex 813 2023-11-13 19:33:29Z herbert $ \documentclass[fontsize=11pt,english,BCOR=10mm,DIV=12,bibliography=totoc,parskip=false, headings=small, headinclude=false,footinclude=false,oneside,abstract=on]{pst-doc} \usepackage{xcolor,pstricks,multido} -\usepackage{auto-pst-pdf-lua} \usepackage{luarandom} \let\pstMathFV\fileversion @@ -21,7 +20,7 @@ x&\mapsto&{\operator@font#1}(x)\end{array}\right.} \begin{document} \title{\texttt{luarandom}} -\subtitle{Create a list of random numbers with or without multiple values; v. 0.01} +\subtitle{Create a list of random numbers with or without multiple values; v. 0.02} \author{Herbert Vo\ss} \docauthor{Herbert Vo\ss} \date{\today} @@ -39,8 +38,8 @@ However, this package will \emph{not} run with other \TeX-engines than Lua\LaTe \section{The Macros} \begin{BDef} -\Lcs{makeSimpleRandomNumberList}\Largb{Left}\Largb{Right}\Largb{N}\% multiple values possible\\ -\Lcs{makeRandomNumberList}\Largb{Left}\Largb{Right}\Largb{N} \% no multiple values!\\ +\Lcs{makeSimpleRandomNumberList}\OptArg{Seed}\Largb{Left}\Largb{Right}\Largb{N}\% multiple values possible\\ +\Lcs{makeRandomNumberList}\OptArg{Seed}\Largb{Left}\Largb{Right}\Largb{N} \% no multiple values!\\ \Lcs{getNumberFromList}\Largb{number} \end{BDef} @@ -61,10 +60,33 @@ The list of the random numbers is saved in the Lua table \texttt{RandomNumbers}. \end{LTXexample} +With the optional argument \verb|[seed number]|, the seed function is not called +with the current time, but with the optional value (integer). -The following example uses PSTricks related packages which cannot be run directly -with Lua\LaTeX. The package \LPack{auto-pst-pdf-lua} will convert the PSTricks stuff -in the baclground into PDF images which will be included in a second run. +\begin{LTXexample}[pos=t] +\small +\makeSimpleRandomNumberList[999]{1}{30}{30}% with multiple values and value seed +\multido{\iA=1+1}{30}{\getNumberFromList{\iA}, } + +\makeRandomNumberList[999]{1}{30}{30}% without multiple values and value seed +\multido{\iA=1+1}{30}{\getNumberFromList{\iA}, } + +\makeSimpleRandomNumberList[999]{1}{30}{30}% with multiple values and value seed +\multido{\iA=1+1}{30}{\getNumberFromList{\iA}, } + +\makeRandomNumberList{1}{30}{30}% without multiple values and time seed +\multido{\iA=1+1}{30}{\getNumberFromList{\iA}, } +\end{LTXexample} + + +\begin{LTXexample}[pos=t] +\makeRandomNumberList{2}{30}{5}% +\multido{\iA=1+1}{5}{\getNumberFromList{\iA}, } +\end{LTXexample} + + +The following example uses PSTricks related packages which can be run directly +with Lua\LaTeX. \begin{LTXexample}[pos=t] @@ -79,7 +101,6 @@ in the baclground into PDF images which will be included in a second run. \end{pspicture} \end{LTXexample} - \section{The code} \lstinputlisting{luarandom.sty} diff --git a/Master/texmf-dist/tex/lualatex/luarandom/luarandom.sty b/Master/texmf-dist/tex/lualatex/luarandom/luarandom.sty index a0be7f3c498..ea13d340b0f 100644 --- a/Master/texmf-dist/tex/lualatex/luarandom/luarandom.sty +++ b/Master/texmf-dist/tex/lualatex/luarandom/luarandom.sty @@ -1,10 +1,10 @@ -% $Id: luarandom.sty 862 2018-12-15 16:25:55Z herbert $ +% $Id: luarandom.sty 813 2023-11-13 19:33:29Z herbert $ %% %% This is file `luarandom.sty'. %% %% IMPORTANT NOTICE: %% -%% luarandom Copyright (C) 2019- Herbert Voss <hvoss@tug.org> +%% luarandom Copyright (C) 2018,2023- 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. @@ -12,8 +12,9 @@ %% \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{luarandom}[2018/12/16 v 0.01 package for random numbers] -\RequirePackage{ifluatex} +\ProvidesPackage{luarandom}[2023/11/12 v 0.02 package for random numbers] +\RequirePackage{iftex} + \def\lua@nl{^^J\space\space\space\space} \newcommand\lua@PackageError[2]{\PackageError{luarandom}{\lua@nl #1^^J}{#2}} \ifluatex\else @@ -39,24 +40,32 @@ function allFound(R) return true end -function makeRandomNumberList(l,r,n) +function makeRandomNumberList(l,r,n,seed) RandomNumbers = {} - math.randomseed(os.time()) + if seed == 0 then + math.randomseed(os.time()) + else + math.randomseed(seed) + end local R = {} local i,j for i=1,n do R[i] = false end repeat local rand = math.random(l,r) - if not R[rand] then - R[rand] = true + if not R[rand+1-l] then + R[rand+1-l] = true RandomNumbers[#RandomNumbers+1] = rand end until allFound(R) end -function makeSimpleRandomNumberList(l,r,n) +function makeSimpleRandomNumberList(l,r,n,seed) RandomNumbers = {} - math.randomseed(os.time()/3) + if seed == 0 then + math.randomseed(os.time()/3) + else + math.randomseed(seed) + end local i for i=1,n do RandomNumbers[#RandomNumbers+1] = math.random(l,r) end end @@ -66,10 +75,10 @@ function getRand(i) end \end{luacode*} -\def\makeRandomNumberList#1#2#3{% - \directlua{makeRandomNumberList(#1,#2,#3)}} -\def\makeSimpleRandomNumberList#1#2#3{% - \directlua{makeSimpleRandomNumberList(#1,#2,#3)}} +\newcommand\makeRandomNumberList[4][0]{% + \directlua{makeRandomNumberList(#2,#3,#4,#1)}} +\newcommand\makeSimpleRandomNumberList[4][0]{% + \directlua{makeSimpleRandomNumberList(#2,#3,#4,#1)}} \def\getNumberFromList#1{\directlua{getRand(#1)}} |