diff options
author | Karl Berry <karl@freefriends.org> | 2017-01-07 23:38:44 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2017-01-07 23:38:44 +0000 |
commit | 59d321e899ed5a0ba1607c5c2ffc39192feea615 (patch) | |
tree | a2da6664231860296e14fff8d6609e580a276aba /Master/texmf-dist/tex/generic/xint/xintexpr.sty | |
parent | 989cfdb299c13ca826bf94eb4cf7b31dd1301a57 (diff) |
xint (8jan17)
git-svn-id: svn://tug.org/texlive/trunk@42892 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/generic/xint/xintexpr.sty')
-rw-r--r-- | Master/texmf-dist/tex/generic/xint/xintexpr.sty | 123 |
1 files changed, 63 insertions, 60 deletions
diff --git a/Master/texmf-dist/tex/generic/xint/xintexpr.sty b/Master/texmf-dist/tex/generic/xint/xintexpr.sty index f53aa7b1e4e..91354f0a86e 100644 --- a/Master/texmf-dist/tex/generic/xint/xintexpr.sty +++ b/Master/texmf-dist/tex/generic/xint/xintexpr.sty @@ -21,8 +21,8 @@ %% same distribution. (The sources need not necessarily be %% in the same archive or directory.) %% --------------------------------------------------------------- -%% The xint bundle 1.2j 2016/12/22 -%% Copyright (C) 2013-2016 by Jean-Francois Burnol +%% The xint bundle 1.2k 2017/01/06 +%% Copyright (C) 2013-2017 by Jean-Francois Burnol %% xintexpr: Expandable expression parser %% --------------------------------------------------------------- \begingroup\catcode61\catcode48\catcode32=10\relax% @@ -81,7 +81,7 @@ \XINTsetupcatcodes% \XINT_providespackage \ProvidesPackage{xintexpr}% - [2016/12/22 1.2j Expandable expression parser (JFB)]% + [2017/01/06 1.2k Expandable expression parser (JFB)]% \catcode`! 11 \def\xint_gob_til_! #1!{}% catcode 11 ! default in xintexpr.sty code. \edef\XINT_expr_lockscan#1!% not used for decimal numbers in xintexpr 1.2 @@ -980,18 +980,58 @@ \let\XINT_flexpr_op_][: \XINT_expr_op_][: \let\XINT_iiexpr_op_][: \XINT_expr_op_][: \catcode`[ 12 \catcode`] 12 -\def\xintListSel:f:csv #1% +\def\xintListSel:x:csv #1% {% - \if ]\noexpand#1\xint_dothis{\expandafter\XINT_listsel:_s\romannumeral`&&@}\fi - \if :\noexpand#1\xint_dothis{\XINT_listsel:_:}\fi + \if ]\noexpand#1\xint_dothis\XINT_listsel:_s\fi + \if :\noexpand#1\xint_dothis\XINT_listxsel:_:\fi \xint_orthat {\XINT_listsel:_nth #1}% }% -\def\XINT_listsel:_nth #1;#2;{\xintNthEltPy:f:csv {\xintNum{#1}}{#2}}% \def\XINT_listsel:_s #1#2;#3;% {% \if-#1\expandafter\xintKeep:f:csv\else\expandafter\xintTrim:f:csv\fi {#1#2}{#3}% }% +\def\XINT_listsel:_nth #1;#2;{\xintNthEltPy:f:csv {\xintNum{#1}}{#2}}% +\def\XINT_listxsel:_: #1#2;#3#4;% +{% + \xint_UDsignsfork + #1#3\XINT_listxsel:_N:N + #1-\XINT_listxsel:_N:P + -#3\XINT_listxsel:_P:N + --\XINT_listxsel:_P:P + \krof #1#2;#3#4;% +}% +\def\XINT_listxsel:_P:P #1;#2;#3;% +{% + \unless\ifnum #1<#2 \expandafter\xint_gobble_iii\fi + \xintKeep:x:csv{#2-#1}{\xintTrim:f:csv{#1}{#3}}% +}% +\def\XINT_listxsel:_N:N #1;#2;#3;% +{% + \expandafter\XINT_listxsel:_N:N_a + \the\numexpr #2-#1\expandafter;\the\numexpr#1+\xintLength:f:csv{#3};#3;% +}% +\def\XINT_listxsel:_N:N_a #1;#2;#3;% +{% + \unless\ifnum #1>\xint_c_ \expandafter\xint_gobble_iii\fi + \xintKeep:x:csv{#1}{\xintTrim:f:csv{\ifnum#2<\xint_c_\xint_c_\else#2\fi}{#3}}% +}% +\def\XINT_listxsel:_N:P #1;#2;#3;{\expandafter\XINT_listxsel:_N:P_a + \the\numexpr #1+\xintLength:f:csv{#3};#2;#3;}% +\def\XINT_listxsel:_N:P_a #1#2;% + {\if -#1\expandafter\XINT_listxsel:_O:P\fi\XINT_listxsel:_P:P #1#2;}% +\def\XINT_listxsel:_O:P\XINT_listxsel:_P:P #1;{\XINT_listxsel:_P:P 0;}% +\def\XINT_listxsel:_P:N #1;#2;#3;{\expandafter\XINT_listxsel:_P:N_a + \the\numexpr #2+\xintLength:f:csv{#3};#1;#3;}% +\def\XINT_listxsel:_P:N_a #1#2;#3;% + {\if -#1\expandafter\XINT_listxsel:_P:O\fi\XINT_listxsel:_P:P #3;#1#2;}% +\def\XINT_listxsel:_P:O\XINT_listxsel:_P:P #1;#2;{\XINT_listxsel:_P:P #1;0;}% +\def\xintListSel:f:csv #1% +{% + \if ]\noexpand#1\xint_dothis{\expandafter\XINT_listsel:_s\romannumeral`&&@}\fi + \if :\noexpand#1\xint_dothis{\XINT_listsel:_:}\fi + \xint_orthat {\XINT_listsel:_nth #1}% +}% \def\XINT_listsel:_: #1;#2;% {% \expandafter\XINT_listsel:_:a @@ -1032,46 +1072,6 @@ \def\XINT_listsel:_P:N_a #1#2;#3;% {\if -#1\expandafter\XINT_listsel:_P:O\fi\XINT_listsel:_P:P #3;#1#2;}% \def\XINT_listsel:_P:O\XINT_listsel:_P:P #1;#2;{\XINT_listsel:_P:P #1;0;}% -\def\xintListSel:x:csv #1% -{% - \if ]\noexpand#1\xint_dothis\XINT_listsel:_s\fi - \if :\noexpand#1\xint_dothis\XINT_listxsel:_:\fi - \xint_orthat {\XINT_listsel:_nth #1}% -}% -\def\XINT_listxsel:_: #1#2;#3#4;% -{% - \xint_UDsignsfork - #1#3\XINT_listxsel:_N:N - #1-\XINT_listxsel:_N:P - -#3\XINT_listxsel:_P:N - --\XINT_listxsel:_P:P - \krof #1#2;#3#4;% -}% -\def\XINT_listxsel:_P:P #1;#2;#3;% -{% - \unless\ifnum #1<#2 \expandafter\xint_gobble_iii\fi - \xintKeep:x:csv{#2-#1}{\xintTrim:f:csv{#1}{#3}}% -}% -\def\XINT_listxsel:_N:N #1;#2;#3;% -{% - \expandafter\XINT_listxsel:_N:N_a - \the\numexpr #2-#1\expandafter;\the\numexpr#1+\xintLength:f:csv{#3};#3;% -}% -\def\XINT_listxsel:_N:N_a #1;#2;#3;% -{% - \unless\ifnum #1>\xint_c_ \expandafter\xint_gobble_iii\fi - \xintKeep:x:csv{#1}{\xintTrim:f:csv{\ifnum#2<\xint_c_\xint_c_\else#2\fi}{#3}}% -}% -\def\XINT_listxsel:_N:P #1;#2;#3;{\expandafter\XINT_listxsel:_N:P_a - \the\numexpr #1+\xintLength:f:csv{#3};#2;#3;}% -\def\XINT_listxsel:_N:P_a #1#2;% - {\if -#1\expandafter\XINT_listxsel:_O:P\fi\XINT_listxsel:_P:P #1#2;}% -\def\XINT_listxsel:_O:P\XINT_listxsel:_P:P #1;{\XINT_listxsel:_P:P 0;}% -\def\XINT_listxsel:_P:N #1;#2;#3;{\expandafter\XINT_listxsel:_P:N_a - \the\numexpr #2+\xintLength:f:csv{#3};#1;#3;}% -\def\XINT_listxsel:_P:N_a #1#2;#3;% - {\if -#1\expandafter\XINT_listxsel:_P:O\fi\XINT_listxsel:_P:P #3;#1#2;}% -\def\XINT_listxsel:_P:O\XINT_listxsel:_P:P #1;#2;{\XINT_listxsel:_P:P #1;0;}% \def\xintKeep:x:csv #1#2% {% \expandafter\xint_gobble_i @@ -1444,9 +1444,9 @@ \edef\XINT_expr_tmpa {\xint_zapspaces_o\XINT_expr_tmpa}% \ifcsname XINT_expr_var_\XINT_expr_tmpa\endcsname \ifnum\expandafter\xintLength\expandafter{\XINT_expr_tmpa}=\@ne - \expandafter\XINT_expr_makedummy \XINT_expr_tmpa - \ifxintverbose\xintMessage {xintexpr}{Info} - {Character \XINT_expr_tmpa\space usable as dummy variable (if letter).}% + \expandafter\XINT_expr_makedummy\XINT_expr_tmpa + \ifxintverbose\xintMessage {xintexpr}{Info}% + {Character \XINT_expr_tmpa\space usable as dummy variable (if with catcode letter).}% \fi \else \expandafter\edef\csname XINT_expr_var_\XINT_expr_tmpa\endcsname @@ -1473,6 +1473,12 @@ }% \xintApplyUnbraced \XINT_expr_makedummy {abcdefghijklmnopqrstuvwxyz}% \xintApplyUnbraced \XINT_expr_makedummy {ABCDEFGHIJKLMNOPQRSTUVWXYZ}% +\def\xintnewdummy #1{% + \XINT_expr_makedummy{#1}% + \ifxintverbose\xintMessage {xintexpr}{Info}% + {Character #1 now usable as dummy variable (if with catcode letter).}% + \fi +}% \edef\XINT_expr_var_nil {\expandafter\noexpand\csname .= \endcsname}% \edef\XINT_expr_onlitteral_nil {\XINT_expr_precedence_*** *\expandafter\noexpand\csname .= \endcsname (}% @@ -2294,16 +2300,13 @@ \let\XINT_flexpr_func_len \XINT_expr_func_len \let\XINT_iiexpr_func_len \XINT_expr_func_len \def\XINT_expr_func_first #1#2#3% - {\expandafter #1\expandafter #2\csname.=\expandafter\XINT_expr_func_firsta - \romannumeral`&&@\XINT_expr_unlock #3,^\endcsname }% -\def\XINT_expr_func_firsta #1,#2^{#1}% + {\expandafter #1\expandafter #2\csname.=% + \xintFirstItem:f:csv{\XINT_expr_unlock #3}\endcsname}% \let\XINT_flexpr_func_first\XINT_expr_func_first \let\XINT_iiexpr_func_first\XINT_expr_func_first -\def\XINT_expr_func_last #1#2#3% will not work in \xintNewExpr if macro param involved - {\expandafter #1\expandafter #2\csname.=\expandafter\XINT_expr_func_lasta - \romannumeral`&&@\XINT_expr_unlock #3,^\endcsname }% -\def\XINT_expr_func_lasta #1,#2% - {\if ^#2 #1\expandafter\xint_gobble_ii\fi \XINT_expr_func_lasta #2}% +\def\XINT_expr_func_last #1#2#3% + {\expandafter #1\expandafter #2\csname.=% + \xintLastItem:f:csv{\XINT_expr_unlock #3}\endcsname}% \let\XINT_flexpr_func_last\XINT_expr_func_last \let\XINT_iiexpr_func_last\XINT_expr_func_last \def\XINT_expr_func_odd #1#2#3% @@ -2636,7 +2639,8 @@ \romannumeral`&&@##2!{~XINTinFloatFac[##1]}{XINTinFloatFac}{}{[##1]}}% }% \xintFor #1 in {ANDof,ORof,XORof,iiMaxof,iiMinof,iiSum,iiPrd, - GCDof,LCMof,Sum,Prd,Maxof,Minof}\do + GCDof,LCMof,Sum,Prd,Maxof,Minof, + Reverse:f,FirstItem:f,LastItem:f}\do {\toks0 \expandafter{\the\toks0\expandafter\def\csname xint#1:csv\endcsname {~xint#1:csv}}% }% @@ -2646,7 +2650,6 @@ \expandafter{\the\toks0\expandafter\def\csname #1:csv\endcsname {~#1:csv}}% }% \toks0 \expandafter{\the\toks0 - \def\xintReverse:f:csv {~xintReverse:f:csv }% \def\xintListSel:x:csv {~xintListSel:f:csv }% }% \odef\XINT_expr_redefinemacros {\the\toks0}% Not \edef ! (subtle) |