[texhax] random order

Uwe Lück uwe.lueck at web.de
Fri Oct 13 16:21:47 CEST 2006

Somebody may be interested in

     CTAN: /macros/generic/misc/random.tex (Donald Arseneau)

yet I haven't tried to replace Oleg's macros by something
building on this package. -- There also is

     CTAN: /macros/latex/contrib/fp/fp-random.sty

which I haven't inspected closely.

     CTAN: /macros/latex/contrib/lcg/

Offers much more than Donald Arseneau's file (probably Tom
won't need most of it) and is well-documented. lcg was the best
I found with Googling CTAN on "random", there are many pages
of hits which I ignore.

HTH -- Uwe.

At 13:04 13.10.06, Oleg Katsitadze wrote:
>On Thu, Oct 12, 2006 at 01:30:12PM -0400, Tom Sgouros wrote:
> > Can someone help me think of a way to get 11 items in a random order?
>In plain TeX you can try the code below.  It will produce
>identical results for different runs if those runs occur
>within the same minute, because random.tex uses the seed
>which changes only every minute -- that's what \time
>\input random
>% Define a new item.
>   \advance\icount by1
>   % Define a macro with the name `n' where n is the item's number.
>   \expandafter\def \csname \number\icount \endcsname
>% Printing of items.
>\def\printitem#1{\csname \number#1\endcsname}
>% Print all defined items in random order.
>   % Unset all flags.
>   \i=\icount
>   \loop
>     \expandafter\let \csname flag\number\i \endcsname a%
>     \advance\i by-1
>     \ifnum\i > 0 \repeat
>   % Print random items, each item once, until every item has been
>   % printed.
>   \i=\icount
>   \loop
>     % Get random number \j.
>     \setrannum{\j}{1}{\icount}%
>     % Print item \j only if its flag is unset.
>     \expandafter\ifx \csname flag\number\j \endcsname a%
>       \expandafter\let \csname flag\number\j \endcsname b% Set the flag.
>       \printitem\j
>       \advance\i by-1
>       \ifnum\i > 0 \printbetweenitems\fi
>     \fi
>     \ifnum\i > 0 \repeat

More information about the texhax mailing list