diff options
Diffstat (limited to 'Master/texmf-dist/doc')
-rw-r--r-- | Master/texmf-dist/doc/latex/xfor/CHANGES | 3 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/xfor/README | 23 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/xfor/sample.tex | 72 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/xfor/xfor.pdf | bin | 0 -> 98358 bytes |
4 files changed, 98 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/latex/xfor/CHANGES b/Master/texmf-dist/doc/latex/xfor/CHANGES new file mode 100644 index 00000000000..8676a338bb1 --- /dev/null +++ b/Master/texmf-dist/doc/latex/xfor/CHANGES @@ -0,0 +1,3 @@ +xfor change log: + +v1.0 (27 June 2007): Initial release diff --git a/Master/texmf-dist/doc/latex/xfor/README b/Master/texmf-dist/doc/latex/xfor/README new file mode 100644 index 00000000000..7b617de5662 --- /dev/null +++ b/Master/texmf-dist/doc/latex/xfor/README @@ -0,0 +1,23 @@ +LaTeX Package : xfor
+
+Last Modified : 27 June 2009
+Version : 1.0 (Initial Release)
+Author : Nicola Talbot
+
+This package redefines \@for so that it is possible to
+prematurely terminate the loop.
+
+The package is supplied using the TeX Directory Structure (TDS).
+Files in texmf directory should go in the corresponding
+$LOCALTEXMF directories.
+
+*Remember to refresh TeX's database*
+
+The package and documentation source code is also supplied as a
+dtx and ins file located in texmf/source.
+
+This material is subject to the LaTeX Project Public License.
+See http://www.ctan.org/tex-archive/help/Catalogue/licenses.lppl.html for the details of that license.
+
+http://theoval.cmp.uea.ac.uk/~nlct/
+
diff --git a/Master/texmf-dist/doc/latex/xfor/sample.tex b/Master/texmf-dist/doc/latex/xfor/sample.tex new file mode 100644 index 00000000000..b1027185b18 --- /dev/null +++ b/Master/texmf-dist/doc/latex/xfor/sample.tex @@ -0,0 +1,72 @@ +\errorcontextlines=100 +\documentclass{article} + +\usepackage{xfor} + +\makeatletter +% \insertinto{new value}{list} +\newcommand{\insertinto}[2]{% +\def\nlst{}% +\@for\n:=#2\do{% +% store new list in \toks@ +\expandafter\toks@\expandafter{\nlst}% +% test current value against new value +\ifnum\n>#1\relax + \edef\newstuff{\number#1,\n}% + % end for loop at the end of this iteration + \@endfortrue +\else + \edef\newstuff{\n}% +\fi +% append new stuff to new list +\ifx\nlst\@empty + \edef\nlst{\newstuff}% +\else + \edef\nlst{\the\toks@,\newstuff}% +\fi +}% +% check to see if for loop was prematurely terminated +\if@endfor + % loop may have been terminated during final iteration, in + % which case \@forremainder is empty. + \ifx\@forremainder\@empty + % do nothing + \else + % loop prematurely ended, append remainder of original list + % to new list + \expandafter\toks@\expandafter{\nlst}% + \edef\nlst{\the\toks@,\@forremainder}% + \fi +\else + % wasn't prematurely terminated, so new value hasn't been added + % add now. + \expandafter\toks@\expandafter{\nlst}% + \ifx\nlst\@empty + \edef\nlst{\number#1}% + \else + \edef\nlst{\the\toks@,\number#1}% + \fi +\fi +\global\let#2=\nlst +} + +\newcommand{\insertionsort}[1]{% +\def\sortedlist{}% +\@for\val:=#1\do{{\insertinto{\val}{\sortedlist}}}% +\let#1=\sortedlist} +\makeatother + +\begin{document} +\def\mylist{1,2,5,9,12,15,18,20}% +\def\newval{11}% +Original list: \mylist. New value: \newval. + +\insertinto{\newval}{\mylist} +New list: \mylist. + +Unsorted list: +\def\mylist{4,2,7,1,10,11,20,15}\mylist. + +\insertionsort{\mylist}% +Sorted list: \mylist. +\end{document} diff --git a/Master/texmf-dist/doc/latex/xfor/xfor.pdf b/Master/texmf-dist/doc/latex/xfor/xfor.pdf Binary files differnew file mode 100644 index 00000000000..5c62d04e07a --- /dev/null +++ b/Master/texmf-dist/doc/latex/xfor/xfor.pdf |