Re: liste di token

#44727
Up
0
Down
::

Scusami ho usato quel comando di geometry perché è stato il primo che mi è venuto in mente che operasse su una lista.

Il mio problema è questo: devo scegliere casualmente da una lista di m oggetti (m diciamo 15) una lista di n (

Qualcosa del genere?
`\documentclass[a4paper]{article}
\usepackage{lcg}

\makeatletter
\g@addto@macro\r@nd{\global\cr@nd\cr@nd}

\newcommand{\rchoice}[4][]{\begingroup\def\excl@list{#4}%
\ifx\relax#1\relax
\reinitrand[first=#2,last=#3]%
\else
\reinitrand[seed=#1,first=#2,last=#3]%
\fi
\def\xyz@{}%
\@for\next:=\excl@list\do{\@namedef{xyz@\romannumeral\next}{}}%
\count\z@=\z@
\@rchoice\endgroup}
\def\@rchoice{%
\ifnum\count\z@=10 \else
\expandafter\@dochoice
\fi}
\def\@dochoice{\rand
\@ifundefined{xyz@\romannumeral\c@rand}{\@goodchoice}{\@rchoice}}
\def\@goodchoice{\@namedef{xyz@\romannumeral\c@rand}{}%
\advance\count\z@\@ne\number\c@rand\relax\space\@rchoice}
\makeatother

\begin{document}

\rchoice[1]{1}{15}{2,3}

\rchoice[1]{1}{15}{2,3}

\rchoice{1}{15}{1,2,3,4,5}

\end{document}`
Ciao
Enrico

Go to top