texlive[68847] Master/texmf-dist: luarandom (14nov23)
commits+karl at tug.org
commits+karl at tug.org
Tue Nov 14 22:06:47 CET 2023
Revision: 68847
https://tug.org/svn/texlive?view=revision&revision=68847
Author: karl
Date: 2023-11-14 22:06:47 +0100 (Tue, 14 Nov 2023)
Log Message:
-----------
luarandom (14nov23)
Modified Paths:
--------------
trunk/Master/texmf-dist/doc/lualatex/luarandom/Changes
trunk/Master/texmf-dist/doc/lualatex/luarandom/README
trunk/Master/texmf-dist/doc/lualatex/luarandom/luarandom-doc.pdf
trunk/Master/texmf-dist/doc/lualatex/luarandom/luarandom-doc.tex
trunk/Master/texmf-dist/tex/lualatex/luarandom/luarandom.sty
Modified: trunk/Master/texmf-dist/doc/lualatex/luarandom/Changes
===================================================================
--- trunk/Master/texmf-dist/doc/lualatex/luarandom/Changes 2023-11-14 21:06:36 UTC (rev 68846)
+++ trunk/Master/texmf-dist/doc/lualatex/luarandom/Changes 2023-11-14 21:06:47 UTC (rev 68847)
@@ -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)
Modified: trunk/Master/texmf-dist/doc/lualatex/luarandom/README
===================================================================
--- trunk/Master/texmf-dist/doc/lualatex/luarandom/README 2023-11-14 21:06:36 UTC (rev 68846)
+++ trunk/Master/texmf-dist/doc/lualatex/luarandom/README 2023-11-14 21:06:47 UTC (rev 68847)
@@ -9,4 +9,4 @@
hvoss at tug.org
-%% $Id: README 862 2018-12-15 16:25:55Z herbert $
+%% $Id: README 813 2023-11-13 19:33:29Z herbert $
Modified: trunk/Master/texmf-dist/doc/lualatex/luarandom/luarandom-doc.pdf
===================================================================
(Binary files differ)
Modified: trunk/Master/texmf-dist/doc/lualatex/luarandom/luarandom-doc.tex
===================================================================
--- trunk/Master/texmf-dist/doc/lualatex/luarandom/luarandom-doc.tex 2023-11-14 21:06:36 UTC (rev 68846)
+++ trunk/Master/texmf-dist/doc/lualatex/luarandom/luarandom-doc.tex 2023-11-14 21:06:47 UTC (rev 68847)
@@ -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 @@
\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 @@
\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,13 +60,36 @@
\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]
\newcounter{RandNo}\setcounter{RandNo}{1}
\def\n{10} \def\N{\the\numexpr\n*\n}
\makeRandomNumberList{1}{\N}{\N}
@@ -79,7 +101,6 @@
\end{pspicture}
\end{LTXexample}
-
\section{The code}
\lstinputlisting{luarandom.sty}
Modified: trunk/Master/texmf-dist/tex/lualatex/luarandom/luarandom.sty
===================================================================
--- trunk/Master/texmf-dist/tex/lualatex/luarandom/luarandom.sty 2023-11-14 21:06:36 UTC (rev 68846)
+++ trunk/Master/texmf-dist/tex/lualatex/luarandom/luarandom.sty 2023-11-14 21:06:47 UTC (rev 68847)
@@ -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 at tug.org>
+%% luarandom Copyright (C) 2018,2023- Herbert Voss <hvoss at 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 at nl{^^J\space\space\space\space}
\newcommand\lua at PackageError[2]{\PackageError{luarandom}{\lua at nl #1^^J}{#2}}
\ifluatex\else
@@ -39,24 +40,32 @@
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 @@
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)}}
More information about the tex-live-commits
mailing list.