summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/xfor
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2007-07-16 16:42:56 +0000
committerKarl Berry <karl@freefriends.org>2007-07-16 16:42:56 +0000
commitddc4d77ba98166cf86d502db2514f63216c9f134 (patch)
tree9d3405493dc35487b2d7a90ae96ec028215cac6a /Master/texmf-dist/doc/latex/xfor
parent33c85af6b9b145413f145c2f42ab33edebe0db80 (diff)
new latex package xfor, 28jun07
git-svn-id: svn://tug.org/texlive/trunk@4626 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/doc/latex/xfor')
-rw-r--r--Master/texmf-dist/doc/latex/xfor/CHANGES3
-rw-r--r--Master/texmf-dist/doc/latex/xfor/README23
-rw-r--r--Master/texmf-dist/doc/latex/xfor/sample.tex72
-rw-r--r--Master/texmf-dist/doc/latex/xfor/xfor.pdfbin0 -> 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
new file mode 100644
index 00000000000..5c62d04e07a
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/xfor/xfor.pdf
Binary files differ