From e0c6872cf40896c7be36b11dcc744620f10adf1d Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Mon, 2 Sep 2019 13:46:59 +0900 Subject: Initial commit --- info/examples/tip/list-mac.tip | 142 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 142 insertions(+) create mode 100644 info/examples/tip/list-mac.tip (limited to 'info/examples/tip/list-mac.tip') diff --git a/info/examples/tip/list-mac.tip b/info/examples/tip/list-mac.tip new file mode 100644 index 0000000000..b8c1f6d72e --- /dev/null +++ b/info/examples/tip/list-mac.tip @@ -0,0 +1,142 @@ +% This macro source file is from the four volume series +% "TeX in Practice" by Stephan von Bechtolsheim, published +% 1993 by Springer-Verlag, New York. +% Copyright 1993 Stephan von Bechtolsheim. +% No warranty or liability is assumed. +% This macro may be copied freely if no fees other than +% media cost or shipping charges are charged and as long +% as this copyright and the following source code itself +% is not changed. Please see the series for further information. +% +% Version: 1.0 +% Date: May 1, 1993 +% +% +% This source code is documented in 20.2.2, p. III-121. +% Original source in file "tokens3.TEX", starting line 263. +\wlog{L: "list-mac.tip" ["tokens3.TEX," l. 263, p. III-121]}% +% This file DOES belong to format "texip." +\InputD{compst.tip} +\catcode`\@ = 11 +\def\@EmptyRefList{} +\def\EmptyListConditional #1{% + TT\fi + \ifx#1\@EmptyRefList +} +\newtoks\@AppendTokOne +\newtoks\@AppendTokTwo +\def\LeftAppendElement #1#2{% + \edef\@AppendTemp{\noexpand\\{#2}}% + \@AppendTokOne = \expandafter{\@AppendTemp}% + \@AppendTokTwo = \expandafter{#1}% + \edef#1{\the\@AppendTokOne \the\@AppendTokTwo}% +} +\def\RightAppendElement #1#2{% + \edef\@AppendTemp{\noexpand\\{#2}}% + \@AppendTokOne = \expandafter{\@AppendTemp}% + \@AppendTokTwo = \expandafter{#1}% + \edef#1{\the\@AppendTokTwo \the\@AppendTokOne}% +} +\def\CarOfList #1#2{% + \def\@CarTemp \\##1##2\@EndCarList{\def#2{##1}}% + \expandafter\@CarTemp#1\@EndCarList +} +\def\CdrOfList #1#2{% + \def\@CdrTemp \\##1##2\@EndCdrList{\def#2{##2}}% + \expandafter\@CdrTemp#1\@EndCdrList +} +\def\DropFirstElementOfList #1{% + \if\EmptyListConditional{#1}% + \errhelp = {\string\DropFirstElementOfList: list is + empty. No first element to drop.}% + \errmessage{\string\DropFirstElementOfList: List + \noexpand#1 is empty.}% + \else + \def\@DropFirstElementTemp \\##1##2\@EndCdrList{\def#1{##2}}% + \expandafter\@DropFirstElementTemp#1\@EndCdrList + \fi +} +\def\CarCarOfList #1#2{% + \let\@CarCarOfListList = #1% + \DropFirstElementOfList{\@CarCarOfListList}% + \CarOfList{\@CarCarOfListList}{#2} +} +\def\ForEveryListElement #1#2{% + \let\@ForEveryList = #1% + \let\@ForEveryListElementMacro = #2% + \@ForEveryListElement +} +\def\@ForEveryListElement{% + \if\EmptyListConditional{\@ForEveryList}% + \let\@ForEveryListElementNext = \relax + \else + \CarOfList{\@ForEveryList}{\@ForEveryListElementElement}% + \@ForEveryListElementMacro{\@ForEveryListElementElement}% + \DropFirstElementOfList{\@ForEveryList}% + \let\@ForEveryListElementNext = \@ForEveryListElement + \fi + \@ForEveryListElementNext +} +\newif\if@MemberList +\def\MemberOfListConditional #1#2{% + TT\fi + \@MemberListfalse + {% + \def\\##1{% + \if\StringsEqualConditional{#2}{##1}% + \global\@MemberListtrue + \fi + }% + #1% + }% + \if@MemberList +} +\def\ReverseList #1#2{% + \def\@ReverseListOut{}% + \ForEveryListElement{#1}{\@ReverseList}% + \let#2 = \@ReverseListOut +} +\def\@ReverseList #1{% + \LeftAppendElement{\@ReverseListOut}{#1}% +} +\def\LastElementOfList #1#2{% + \ReverseList{#1}{#1}% + \CarOfList{#1}{#2}% + \ReverseList{#1}{#1}% +} +\def\DropLastElementOfList #1{% + \ReverseList{#1}{#1}% + \DropFirstElementOfList{#1}% + \ReverseList{#1}{#1}% +} +\def\NumberOfListElements #1#2{% + \let\@NumberOfListElementsList = #1% + \def\@NumberOfListElementsCount{#2}% + \@NumberOfListElementsCount = 0 + \@NumberOfListElements +} +\def\@NumberOfListElements{% + \if\EmptyListConditional{\@NumberOfListElementsList}% + \let\@NumberOfListElementsNext = \relax + \else + \advance\@NumberOfListElementsCount by 1 + \DropFirstElementOfList{\@NumberOfListElementsList}% + \let\@NumberOfListElementsNext = \@NumberOfListElements + \fi + \@NumberOfListElementsNext +} +\newcount\@NumberOfListElCCount +\def\NumberOfListElementsNumConditional #1{% + 0=0\fi + \NumberOfListElements{#1}{\@NumberOfListElCCount}% + \ifnum\@NumberOfListElCCount +} +\def\CombineTwoLists #1#2#3{% + \def\@CombineTwoLists{\def\@CombineTwoListsResult}% + \expandafter\expandafter\expandafter + \expandafter\expandafter\expandafter + \expandafter\@CombineTwoLists + \expandafter\expandafter\expandafter{\expandafter#1#2}% + \let #3 = \@CombineTwoListsResult +} +\catcode`\@ = 12 -- cgit v1.2.3