summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/lualatex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2023-11-14 21:06:47 +0000
committerKarl Berry <karl@freefriends.org>2023-11-14 21:06:47 +0000
commitcac23e5cf5d61139ea64c9a31a32e52d3b30dcc0 (patch)
tree8e70e02f1ffbcc35f35afb686ade32cef26ddf57 /Master/texmf-dist/tex/lualatex
parentb3f721e9b9d6e76e9ba321c8a82d8c275c579fc1 (diff)
luarandom (14nov23)
git-svn-id: svn://tug.org/texlive/trunk@68847 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/lualatex')
-rw-r--r--Master/texmf-dist/tex/lualatex/luarandom/luarandom.sty37
1 files changed, 23 insertions, 14 deletions
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)}}