From 6751ea76abc2df59197ab3c20fe780ecf9de81fb Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Tue, 28 Oct 2014 22:36:18 +0000 Subject: xint (28oct14) git-svn-id: svn://tug.org/texlive/trunk@35458 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/tex/generic/xint/xintexpr.sty | 2508 +++++++++++++++++------ 1 file changed, 1850 insertions(+), 658 deletions(-) (limited to 'Master/texmf-dist/tex/generic/xint/xintexpr.sty') diff --git a/Master/texmf-dist/tex/generic/xint/xintexpr.sty b/Master/texmf-dist/tex/generic/xint/xintexpr.sty index 3f60831f485..a73c5736307 100644 --- a/Master/texmf-dist/tex/generic/xint/xintexpr.sty +++ b/Master/texmf-dist/tex/generic/xint/xintexpr.sty @@ -20,11 +20,11 @@ %% original source files, as listed above, are part of the %% same distribution. (The sources need not necessarily be %% in the same archive or directory.) -%%---------------------------------------------------------------- -%% The xint bundle (version 1.09n of April 1st, 2014) -%% xintexpr: Expandable expression parser +%% --------------------------------------------------------------- +%% The xint bundle v1.1 (2014/10/28) %% Copyright (C) 2013-2014 by Jean-Francois Burnol -%%---------------------------------------------------------------- +%% xintexpr: Expandable expression parser +%% --------------------------------------------------------------- \begingroup\catcode61\catcode48\catcode32=10\relax% \catcode13=5 % ^^M \endlinechar=13 % @@ -36,10 +36,10 @@ \catcode45=12 % - \catcode46=12 % . \catcode58=12 % : - \def\space { }% - \let\z\endgroup + \def\z {\endgroup}% \expandafter\let\expandafter\x\csname ver@xintexpr.sty\endcsname \expandafter\let\expandafter\w\csname ver@xintfrac.sty\endcsname + \expandafter\let\expandafter\t\csname ver@xinttools.sty\endcsname \expandafter \ifx\csname PackageInfo\endcsname\relax \def\y#1#2{\immediate\write-1{Package #1 Info: #2.}}% @@ -53,287 +53,349 @@ \else \ifx\x\relax % plain-TeX, first loading of xintexpr.sty \ifx\w\relax % but xintfrac.sty not yet loaded. - \y{xintexpr}{now issuing \string\input\space xintfrac.sty}% - \def\z{\endgroup\input xintfrac.sty\relax}% + \expandafter\def\expandafter\z\expandafter + {\z\input xintfrac.sty\relax}% + \fi + \ifx\t\relax % but xinttools.sty not yet loaded. + \expandafter\def\expandafter\z\expandafter + {\z\input xinttools.sty\relax}% \fi \else \def\empty {}% \ifx\x\empty % LaTeX, first loading, % variable is initialized, but \ProvidesPackage not yet seen \ifx\w\relax % xintfrac.sty not yet loaded. - \y{xintexpr}{now issuing \string\RequirePackage{xintfrac}}% - \def\z{\endgroup\RequirePackage{xintfrac}}% + \expandafter\def\expandafter\z\expandafter + {\z\RequirePackage{xintfrac}}% + \fi + \ifx\t\relax % xinttools.sty not yet loaded. + \expandafter\def\expandafter\z\expandafter + {\z\RequirePackage{xinttools}}% \fi \else - \y{xintexpr}{I was already loaded, aborting input}% - \aftergroup\endinput + \aftergroup\endinput % xintexpr already loaded. \fi \fi \fi \z% -\begingroup\catcode61\catcode48\catcode32=10\relax% - \catcode13=5 % ^^M - \endlinechar=13 % - \catcode123=1 % { - \catcode125=2 % } - \catcode64=11 % @ - \catcode35=6 % # - \catcode44=12 % , - \catcode45=12 % - - \catcode46=12 % . - \catcode58=12 % : - \ifdefined\PackageInfo - \def\y#1#2{\PackageInfo{#1}{#2}}% - \else - \def\y#1#2{\immediate\write-1{Package #1 Info: #2.}}% - \fi - \def\empty {}% - \expandafter\let\expandafter\w\csname ver@xintfrac.sty\endcsname - \ifx\w\relax % Plain TeX, user gave a file name at the prompt - \y{xintexpr}{Loading of package xintfrac failed, aborting input}% - \aftergroup\endinput - \fi - \ifx\w\empty % LaTeX, user gave a file name at the prompt - \y{xintexpr}{Loading of package xintfrac failed, aborting input}% - \aftergroup\endinput - \fi -\endgroup% \XINTsetupcatcodes% \XINT_providespackage \ProvidesPackage{xintexpr}% - [2014/04/01 v1.09n Expandable expression parser (jfB)]% -\def\xint_gob_til_! #1!{}% nota bene: this ! has catcode 11 -\expandafter\def\expandafter -\XINT_expr_lock\expandafter#\expandafter1\expandafter !\expandafter - {\expandafter\expandafter\space\csname .=#1\endcsname }% + [2014/10/28 v1.1 Expandable expression parser (jfB)]% +\def\xint_gob_til_! #1!{}% this ! has catcode 11 +\edef\XINT_expr_lockscan#1!{\noexpand\expandafter\space\noexpand\csname .=#1\endcsname }% +\edef\XINT_expr_lockit #1{\noexpand\expandafter\space\noexpand\csname .=#1\endcsname }% +\def\XINT_expr_inintpart #1!{\XINT_num{#1}}% +\def\XINT_expr_infracpart #1e#2!{#1![\the\numexpr#2-\xintLength{#1}]!}% +\def\XINT_expr_inexppart e#1!{![\the\numexpr #1]!}% \def\XINT_expr_unlock {\expandafter\XINT_expr_unlock_a\string }% \def\XINT_expr_unlock_a #1.={}% \def\XINT_expr_unexpectedtoken {\xintError:ignored }% -\def\XINT_newexpr_setprefix #1>{\noexpand\romannumeral-`0}% -\def\xint_UDxintrelaxfork #1\xint_relax #2#3\krof {#2}% -\def\xint_protect {\noexpand\xint_protect\noexpand }% 1.09j -\def\XINT_expr_done {!\XINT_expr_usethe\xint_protect\XINT_expr_print }% -\let\XINT_iiexpr_done \XINT_expr_done -\def\XINT_iexpr_done {!\XINT_expr_usethe\xint_protect\XINT_iexpr_print }% -\def\XINT_flexpr_done {!\XINT_expr_usethe\xint_protect\XINT_flexpr_print }% -\def\XINT_boolexpr_done {!\XINT_expr_usethe\xint_protect\XINT_boolexpr_print }% -\protected\def\XINT_expr_usethe #1#2#3% modified in 1.09j - {\xintError:missing_xintthe!\show#3missing xintthe (see log)!}% -\def\xintthe #1{\romannumeral-`0\expandafter\xint_gobble_iii\romannumeral-`0#1}% -\let\XINT_expr_print \XINT_expr_unlock -\def\XINT_iexpr_print #1{\xintRound:csv {\XINT_expr_unlock #1}}% -\def\XINT_flexpr_print #1{\xintFloat:csv {\XINT_expr_unlock #1}}% -\def\XINT_boolexpr_print #1{\xintIsTrue:csv{\XINT_expr_unlock #1}}% +\let\XINT_expr_done\space +\def\XINT_expr_wrap { !\XINT_expr_usethe\XINT_protectii\XINT_expr_print }% +\def\XINT_iiexpr_wrap { !\XINT_expr_usethe\XINT_protectii\XINT_iiexpr_print }% +\def\XINT_protectii #1{\noexpand\XINT_protectii\noexpand #1\noexpand }% +\protected\def\XINT_expr_usethe\XINT_protectii {\xintError:missing_xintthe!}% +\def\XINT_expr_print #1{\xintSPRaw::csv {\XINT_expr_unlock #1}}% +\def\XINT_iiexpr_print #1{\xintCSV::csv {\XINT_expr_unlock #1}}% +\def\XINT_boolexpr_print #1{\xintIsTrue::csv {\XINT_expr_unlock #1}}% \def\xintexpr {\romannumeral0\xinteval }% +\def\xintiexpr {\romannumeral0\xintieval }% \def\xintfloatexpr {\romannumeral0\xintfloateval }% \def\xintiiexpr {\romannumeral0\xintiieval }% -\def\xinteval - {\expandafter\XINT_expr_until_end_a \romannumeral-`0\XINT_expr_getnext }% -\def\xintfloateval - {\expandafter\XINT_flexpr_until_end_a\romannumeral-`0\XINT_expr_getnext }% -\def\xintiieval - {\expandafter\XINT_iiexpr_until_end_a\romannumeral-`0\XINT_expr_getnext }% \def\xinttheexpr - {\romannumeral-`0\expandafter\xint_gobble_iii\romannumeral0\xinteval }% -\def\xintthefloatexpr - {\romannumeral-`0\expandafter\xint_gobble_iii\romannumeral0\xintfloateval }% + {\romannumeral-`0\expandafter\XINT_expr_print\romannumeral0\xintbareeval }% +\def\xinttheiexpr {\romannumeral-`0\xintthe\xintiexpr }% +\def\xintthefloatexpr {\romannumeral-`0\xintthe\xintfloatexpr }% \def\xinttheiiexpr - {\romannumeral-`0\expandafter\xint_gobble_iii\romannumeral0\xintiieval }% -\def\xintiexpr {\romannumeral0\expandafter\expandafter\expandafter - \XINT_iexpr_done \expandafter\xint_gobble_iv\romannumeral0\xinteval }% -\def\xinttheiexpr {\romannumeral-`0\expandafter\expandafter\expandafter - \XINT_iexpr_print\expandafter\xint_gobble_iv\romannumeral0\xinteval }% -\def\xintboolexpr {\romannumeral0\expandafter\expandafter\expandafter - \XINT_boolexpr_done \expandafter\xint_gobble_iv\romannumeral0\xinteval }% -\def\xinttheboolexpr {\romannumeral-`0\expandafter\expandafter\expandafter - \XINT_boolexpr_print\expandafter\xint_gobble_iv\romannumeral0\xinteval }% -\let\xintnumexpr \xintiexpr % deprecated -\let\xintthenumexpr\xinttheiexpr % deprecated -\def\xintifboolexpr #1% - {\romannumeral0\xintifnotzero {\xinttheexpr #1\relax}}% -\def\xintifboolfloatexpr #1% - {\romannumeral0\xintifnotzero {\xintthefloatexpr #1\relax}}% -\def\xintifbooliiexpr #1% - {\romannumeral0\xintifnotzero {\xinttheiiexpr #1\relax}}% -\def\XINT_expr_getnext -{% - \expandafter\XINT_expr_getnext_checkforbraced_a - \romannumeral-`0\romannumeral-`0% + {\romannumeral-`0\expandafter\XINT_iiexpr_print\romannumeral0\xintbareiieval }% +\def\xintthe #1{\romannumeral-`0\expandafter\xint_gobble_iii\romannumeral-`0#1}% +\def\xintthecoords #1{\romannumeral-`0\expandafter\expandafter\expandafter + \XINT_thecoords_a + \expandafter\xint_gobble_iii\romannumeral0#1}% +\def\XINT_thecoords_a #1#2% #1=print macro, indispensible for scientific notation + {\expandafter\XINT_expr_unlock\csname.=\expandafter\XINT_thecoords_b + \romannumeral-`0#1#2,!,!,^\endcsname }% +\def\XINT_thecoords_b #1#2,#3#4,% + {\xint_gob_til_! #3\XINT_thecoords_c ! (#1#2, #3#4)\XINT_thecoords_b }% +\def\XINT_thecoords_c #1^{}% +\def\xintbareeval + {\expandafter\XINT_expr_until_end_a\romannumeral-`0\XINT_expr_getnext }% +\def\xintbarefloateval + {\expandafter\XINT_flexpr_until_end_a\romannumeral-`0\XINT_expr_getnext }% +\def\xintbareiieval + {\expandafter\XINT_iiexpr_until_end_a\romannumeral-`0\XINT_expr_getnext }% +\def\xinteval {\expandafter\XINT_expr_wrap\romannumeral0\xintbareeval }% +\def\xintiieval {\expandafter\XINT_iiexpr_wrap\romannumeral0\xintbareiieval }% +\def\xintieval #1% + {\ifx [#1\expandafter\XINT_iexpr_withopt\else\expandafter\XINT_iexpr_noopt \fi #1}% +\def\XINT_iexpr_noopt + {\expandafter\XINT_iexpr_wrap \expandafter 0\romannumeral0\xintbareeval }% +\def\XINT_iexpr_withopt [#1]% +{% + \expandafter\XINT_iexpr_wrap\expandafter + {\the\numexpr \xint_zapspaces #1 \xint_bye\xint_bye\expandafter}% + \romannumeral0\xintbareeval +}% +\def\XINT_iexpr_wrap #1#2% +{% + \expandafter\XINT_expr_wrap + \csname .=\xintRound::csv {#1}{\XINT_expr_unlock #2}\endcsname +}% +\def\xintfloateval #1% +{% + \ifx [#1\expandafter\XINT_flexpr_withopt_a\else\expandafter\XINT_flexpr_noopt + \fi #1% }% -\def\XINT_expr_getnext_checkforbraced_a #1% was done later in <1.09i +\def\XINT_flexpr_noopt {% - \expandafter\XINT_expr_getnext_checkforbraced_b\expandafter - {\romannumeral-`0#1}% + \expandafter\XINT_flexpr_withopt_b\expandafter\xinttheDigits + \romannumeral0\xintbarefloateval }% -\def\XINT_expr_getnext_checkforbraced_b #1% +\def\XINT_flexpr_withopt_a [#1]% {% - \XINT_expr_getnext_checkforbraced_c #1\xint_relax\Z {#1}% + \expandafter\XINT_flexpr_withopt_b\expandafter + {\the\numexpr\xint_zapspaces #1 \xint_bye\xint_bye\expandafter}% + \romannumeral0\xintbarefloateval }% -\def\XINT_expr_getnext_checkforbraced_c #1#2% +\def\XINT_flexpr_withopt_b #1#2% {% - \xint_UDxintrelaxfork - #1\XINT_expr_getnext_wasemptyorspace - #2\XINT_expr_getnext_gotonetoken_wehope - \xint_relax\XINT_expr_getnext_gotbracedstuff - \krof -}% doubly braced things are not acceptable, will cause errors. -\def\XINT_expr_getnext_wasemptyorspace #1{\XINT_expr_getnext }% -\def\XINT_expr_getnext_gotbracedstuff #1\xint_relax\Z #2% + \expandafter\XINT_flexpr_wrap\csname .;#1.=% ; and not : as before b'cause NewExpr + \XINTinFloat::csv {#1}{\XINT_expr_unlock #2}\endcsname +}% +\def\XINT_flexpr_wrap { !\XINT_expr_usethe\XINT_protectii\XINT_flexpr_print }% +\def\XINT_flexpr_print #1% {% - \expandafter\XINT_expr_getop\csname .=#2\endcsname + \expandafter\xintPFloat::csv + \romannumeral-`0\expandafter\XINT_expr_unlock_sp\string #1!% }% -\def\XINT_expr_getnext_gotonetoken_wehope\Z #1% +\catcode`: 12 + \def\XINT_expr_unlock_sp #1.;#2.=#3!{{#2}{#3}}% +\catcode`: 11 +\def\xintboolexpr {\romannumeral0\expandafter\expandafter\expandafter + \XINT_boolexpr_done \expandafter\xint_gobble_iv\romannumeral0\xinteval }% +\def\xinttheboolexpr {\romannumeral-`0\expandafter\expandafter\expandafter + \XINT_boolexpr_print\expandafter\xint_gobble_iv\romannumeral0\xinteval }% +\def\XINT_boolexpr_done { !\XINT_expr_usethe\XINT_protectii\XINT_boolexpr_print }% +\def\xintifboolexpr #1{\romannumeral0\xintifnotzero {\xinttheexpr #1\relax}}% +\def\xintifboolfloatexpr #1{\romannumeral0\xintifnotzero {\xintthefloatexpr #1\relax}}% +\def\xintifbooliiexpr #1{\romannumeral0\xintifnotzero {\xinttheiiexpr #1\relax}}% +\def\XINT_::_end #1,#2{\xint_gobble_i #2}% +\def\xintCSV::csv #1{\expandafter\XINT_csv::_a\romannumeral-`0#1,^,}% +\def\XINT_csv::_a {\XINT_csv::_b {}}% +\def\XINT_csv::_b #1#2,{\XINT_csv::_c #2,{#1}}% +\def\XINT_csv::_c #1{\if ^#1\expandafter\XINT_::_end\fi\XINT_csv::_d #1}% +\def\XINT_csv::_d #1,#2{\XINT_csv::_b {#2, #1}}% possibly, item #1 is empty. +\def\xintSPRaw {\romannumeral0\xintspraw }% +\def\xintspraw #1{\expandafter\XINT_spraw\romannumeral-`0#1[\W]}% +\def\XINT_spraw #1[#2#3]{\xint_gob_til_W #2\XINT_spraw_a\W\XINT_spraw_p #1[#2#3]}% +\def\XINT_spraw_a\W\XINT_spraw_p #1[\W]{ #1}% +\def\XINT_spraw_p #1[\W]{\xintpraw {#1}}% +\def\xintSPRaw::csv #1{\romannumeral0\expandafter\XINT_spraw::_a\romannumeral-`0#1,^,}% +\def\XINT_spraw::_a {\XINT_spraw::_b {}}% +\def\XINT_spraw::_b #1#2,{\XINT_spraw::_c #2,{#1}}% +\def\XINT_spraw::_c #1{\if ,#1\xint_dothis\XINT_spraw::_e\fi + \if ^#1\xint_dothis\XINT_::_end\fi + \xint_orthat\XINT_spraw::_d #1}% +\def\XINT_spraw::_d #1,{\expandafter\XINT_spraw::_e\romannumeral0\XINT_spraw #1[\W],}% +\def\XINT_spraw::_e #1,#2{\XINT_spraw::_b {#2, #1}}% +\def\xintIsTrue::csv #1{\romannumeral0\expandafter\XINT_istrue::_a\romannumeral-`0#1,^,}% +\def\XINT_istrue::_a {\XINT_istrue::_b {}}% +\def\XINT_istrue::_b #1#2,{\XINT_istrue::_c #2,{#1}}% +\def\XINT_istrue::_c #1{\if ,#1\xint_dothis\XINT_istrue::_e\fi + \if ^#1\xint_dothis\XINT_::_end\fi + \xint_orthat\XINT_istrue::_d #1}% +\def\XINT_istrue::_d #1,{\expandafter\XINT_istrue::_e\romannumeral0\xintisnotzero {#1},}% +\def\XINT_istrue::_e #1,#2{\XINT_istrue::_b {#2, #1}}% +\def\XINT_:::_end #1,#2#3{\xint_gobble_i #3}% +\def\xintRound::csv #1#2{\romannumeral0\expandafter\XINT_round::_b\expandafter + {\the\numexpr#1\expandafter}\expandafter{\expandafter}\romannumeral-`0#2,^,}% +\def\XINT_round::_b #1#2#3,{\XINT_round::_c #3,{#1}{#2}}% +\def\XINT_round::_c #1{\if ,#1\xint_dothis\XINT_round::_e\fi + \if ^#1\xint_dothis\XINT_:::_end\fi + \xint_orthat\XINT_round::_d #1}% +\def\XINT_round::_d #1,#2{% + \expandafter\XINT_round::_e\romannumeral0\ifnum#2>\xint_c_ + \expandafter\xintround\else\expandafter\xintiround\fi {#2}{#1},{#2}}% +\def\XINT_round::_e #1,#2#3{\XINT_round::_b {#2}{#3, #1}}% +\def\XINTinFloat::csv #1#2{\romannumeral0\expandafter\XINT_infloat::_b\expandafter + {\the\numexpr #1\expandafter}\expandafter{\expandafter}\romannumeral-`0#2,^,}% +\def\XINT_infloat::_b #1#2#3,{\XINT_infloat::_c #3,{#1}{#2}}% +\def\XINT_infloat::_c #1{\if ,#1\xint_dothis\XINT_infloat::_e\fi + \if ^#1\xint_dothis\XINT_:::_end\fi + \xint_orthat\XINT_infloat::_d #1}% +\def\XINT_infloat::_d #1,#2% + {\expandafter\XINT_infloat::_e\romannumeral0\XINTinfloat [#2]{#1},{#2}}% +\def\XINT_infloat::_e #1,#2#3{\XINT_infloat::_b {#2}{#3, #1}}% +\def\xintPFloat::csv #1#2{\romannumeral0\expandafter\XINT_pfloat::_b\expandafter + {\the\numexpr #1\expandafter}\expandafter{\expandafter}\romannumeral-`0#2,^,}% +\def\XINT_pfloat::_b #1#2#3,{\XINT_pfloat::_c #3,{#1}{#2}}% +\def\XINT_pfloat::_c #1{\if ,#1\xint_dothis\XINT_pfloat::_e\fi + \if ^#1\xint_dothis\XINT_:::_end\fi + \xint_orthat\XINT_pfloat::_d #1}% +\def\XINT_pfloat::_d #1,#2% + {\expandafter\XINT_pfloat::_e\romannumeral0\XINT_pfloat_opt [\xint_relax #2]{#1},{#2}}% +\def\XINT_pfloat::_e #1,#2#3{\XINT_pfloat::_b {#2}{#3, #1}}% +\def\XINT_expr_getnext #1% +{% + \expandafter\XINT_expr_getnext_a\romannumeral-`0#1% +}% +\def\XINT_expr_getnext_a #1% {% screens out sub-expressions and \count or \dimen registers/variables \xint_gob_til_! #1\XINT_expr_subexpr !% recall this ! has catcode 11 \ifcat\relax#1% \count or \numexpr etc... token or count, dimen, skip cs - \expandafter\XINT_expr_countdimenetc_fork + \expandafter\XINT_expr_countetc \else - \expandafter\expandafter\expandafter - \XINT_expr_getnext_onetoken_fork\expandafter\string + \expandafter\expandafter\expandafter\XINT_expr_getnextfork\expandafter\string \fi #1% }% \def\XINT_expr_subexpr !#1\fi !{\expandafter\XINT_expr_getop\xint_gobble_iii }% -\def\XINT_expr_countdimenetc_fork #1% +\def\XINT_expr_countetc #1% {% \ifx\count#1\else\ifx#1\dimen\else\ifx#1\numexpr\else\ifx#1\dimexpr\else - \ifx\skip#1\else\ifx\glueexpr#1\else - \XINT_expr_unpackvariable - \fi\fi\fi\fi\fi\fi + \ifx\skip#1\else\ifx\glueexpr#1\else\ifx\fontdimen#1\else + \XINT_expr_unpackvar + \fi\fi\fi\fi\fi\fi\fi \expandafter\XINT_expr_getnext\number #1% }% -\def\XINT_expr_unpackvariable\fi\fi\fi\fi\fi\fi\expandafter\XINT_expr_getnext - \number #1{\fi\fi\fi\fi\fi\fi - \expandafter\XINT_expr_getop\csname .=\number#1\endcsname }% +\def\XINT_expr_unpackvar\fi\fi\fi\fi\fi\fi\fi\expandafter\XINT_expr_getnext\number #1% + {\fi\fi\fi\fi\fi\fi\fi\expandafter\XINT_expr_getop\csname .=\number#1\endcsname }% \begingroup \lccode`*=`# \lowercase{\endgroup -\def\XINT_expr_sixwayfork #1(-.+*#2#3\krof {#2}% -\def\XINT_expr_getnext_onetoken_fork #1% -{% The * is in truth catcode 12 #. For (hacking) use with \xintNewExpr. - \XINT_expr_sixwayfork - #1-.+*{\xint_c_xviii ({}}% back to until for oparen triggering - (#1.+*{-}% - (-#1+*{\XINT_expr_scandec_II .}% - (-.#1*{\XINT_expr_getnext }% - (-.+#1{\XINT_expr_scandec_II }% - (-.+*{\XINT_expr_scan_dec_or_func #1}% - \krof +\def\XINT_expr_getnextfork #1{% + \if#1*\xint_dothis {\XINT_expr_scan_macropar *}\fi + \if#1[\xint_dothis {\xint_c_xviii ({}}\fi + \if#1+\xint_dothis \XINT_expr_getnext \fi + \if#1.\xint_dothis {\XINT_expr_scandec_II\XINT_expr_infracpart}\fi + \if#1-\xint_dothis -\fi + \if#1(\xint_dothis {\xint_c_xviii ({}}\fi + \xint_orthat {\XINT_expr_scan_nbr_or_func #1}% }}% -\def\XINT_expr_scan_dec_or_func #1% this #1 has necessarily here catcode 12 +\def\XINT_expr_scan_macropar #1#2{\expandafter\XINT_expr_getop\csname .=#1#2\endcsname }% +\catcode96 11 % ` +\def\XINT_expr_scan_nbr_or_func #1% this #1 has necessarily here catcode 12 {% - \ifnum \xint_c_ix<1#1 - \expandafter\XINT_expr_scandec_I - \else - \if #1"\expandafter\expandafter\expandafter\XINT_expr_scanhex_I - \else % We assume we are dealing with a function name!! - \expandafter\expandafter\expandafter\XINT_expr_scanfunc - \fi - \fi #1% + \if "#1\xint_dothis \XINT_expr_scanhex_I\fi + \if `#1\xint_dothis {\XINT_expr_onlitteral_`}\fi + \ifnum \xint_c_ix<1#1 \xint_dothis \XINT_expr_scandec_I\fi + \xint_orthat \XINT_expr_scanfunc #1% }% -\def\XINT_expr_scanfunc +\catcode96 12 % ` +\def\XINT_expr_scandec_I {% - \expandafter\XINT_expr_func\romannumeral-`0\XINT_expr_scanfunc_c + \expandafter\XINT_expr_getop\romannumeral-`0\expandafter + \XINT_expr_lockscan\romannumeral0\expandafter\XINT_expr_inintpart + \romannumeral-`0\XINT_expr_scanintpart_b }% -\def\XINT_expr_scanfunc_c #1% +\def\XINT_expr_scandec_II {% - \expandafter #1\romannumeral-`0\expandafter - \XINT_expr_scanfunc_a\romannumeral-`0\romannumeral-`0% + \expandafter\XINT_expr_getop\romannumeral-`0\expandafter + \XINT_expr_lockscan\romannumeral0\expandafter\XINT_expr_inintpart + \romannumeral-`0\XINT_expr_scanfracpart_b +}% +\def\XINT_expr_scanintpart_a #1% +{% careful that ! has catcode letter here + \ifcat \relax #1\xint_dothis{!!#1}\fi % stops the scan + \if e#1\xint_dothis{\expandafter\XINT_expr_inexppart + \romannumeral-`0\XINT_expr_scanexppart_a e}\fi + \if E#1\xint_dothis{\expandafter\XINT_expr_inexppart + \romannumeral-`0\XINT_expr_scanexppart_a e}\fi + % \if @#1\xint_dothis{!*#1}\fi % tacit multiplication later + % \if _#1\xint_dothis{!*#1}\fi % tacit multiplication for variables + \ifcat a#1\xint_dothis{!!*#1}\fi % includes subexpressions (#1=! letter) + \xint_orthat {\expandafter\XINT_expr_scanintpart_aa\string #1}% }% -\def\XINT_expr_scanfunc_a #1% please no braced things here! +\def\XINT_expr_scanintpart_aa #1% {% - \ifcat #1\relax % missing opening parenthesis, probably - \expandafter\XINT_expr_scanfunc_panic - \else - \xint_afterfi{\expandafter\XINT_expr_scanfunc_b \string #1}% - \fi + \if .#1\xint_dothis\XINT_expr_scandec_transition\fi + \ifnum \xint_c_ix<1#1 \xint_dothis\XINT_expr_scanintpart_b\fi + \xint_orthat {!!}#1% }% -\def\xint_UDparenfork #1()#2#3\krof {#2}% -\def\XINT_expr_scanfunc_b #1% +\def\XINT_expr_scanintpart_b #1#2% {% - \xint_UDparenfork - #1){(}% and then \XINT_expr_func - (#1{(}% and then \XINT_expr_func (this is for bool/toggle names) - (){\XINT_expr_scanfunc_c #1}% - \krof + \expandafter #1\romannumeral-`0\expandafter + \XINT_expr_scanintpart_a\romannumeral-`0#2% }% -\def\XINT_expr_scanfunc_panic {\xintError:bigtroubleahead(0\relax }% -\def\XINT_expr_func #1(% common to expr and flexpr and iiexpr +\def\XINT_expr_scandec_transition .#1% {% - \xint_c_xviii @{#1}% functions have the highest priority. + \expandafter\XINT_expr_scandec_trans_a\romannumeral-`0#1% }% -\def\XINT_expr_scandec_I +\def\XINT_expr_scandec_trans_a #1% {% - \expandafter\XINT_expr_getop\romannumeral-`0\expandafter - \XINT_expr_lock\romannumeral-`0\XINT_expr_scanintpart_b + \if .#1\xint_dothis{!!..}\fi + \xint_orthat {\expandafter\XINT_expr_infracpart + \romannumeral-`0\XINT_expr_scanfracpart_a #1}% }% -\def\XINT_expr_scandec_II +\def\XINT_expr_scanfracpart_a #1% {% - \expandafter\XINT_expr_getop\romannumeral-`0\expandafter - \XINT_expr_lock\romannumeral-`0\XINT_expr_scanfracpart_b -}% -\def\XINT_expr_scanintpart_a #1% Please no braced material: 123{FORBIDDEN} -{% careful that ! has catcode letter here - \ifcat #1\relax\else - \ifx !#1\else - \expandafter\expandafter\expandafter - \xint_thirdofthree - \fi\fi - \xint_firstoftwo !% this stops the scan - {\expandafter\XINT_expr_scanintpart_aa\string }#1% + \ifcat \relax #1\xint_dothis{e!#1}\fi % stops the scan + \if e#1\xint_dothis{\XINT_expr_scanexppart_a e}\fi + \if E#1\xint_dothis{\XINT_expr_scanexppart_a e}\fi + \ifcat a#1\xint_dothis{e!*#1}\fi % and also the case of subexpressions (!) + \xint_orthat {\expandafter\XINT_expr_scanfracpart_aa\string #1}% }% -\def\XINT_expr_scanintpart_aa #1% +\def\XINT_expr_scanfracpart_aa #1% {% \ifnum \xint_c_ix<1#1 - \expandafter\XINT_expr_scanintpart_b + \expandafter\XINT_expr_scanfracpart_b \else - \if .#1% - \expandafter\expandafter\expandafter - \XINT_expr_scandec_transition - \else % gather what we got so far, leave catcode 12 #1 in stream - \expandafter\expandafter\expandafter !% ! of catcode 11, space needed - \fi + \xint_afterfi {e!}% \fi #1% }% -\def\XINT_expr_scanintpart_b #1% +\def\XINT_expr_scanfracpart_b #1#2% {% \expandafter #1\romannumeral-`0\expandafter - \XINT_expr_scanintpart_a\romannumeral-`0\romannumeral-`0% + \XINT_expr_scanfracpart_a\romannumeral-`0#2% }% -\def\XINT_expr_scandec_transition .% +\def\XINT_expr_scanexppart_a #1#2% {% - \expandafter.\romannumeral-`0\expandafter - \XINT_expr_scanfracpart_a\romannumeral-`0\romannumeral-`0% + \expandafter #1\romannumeral-`0\expandafter + \XINT_expr_scanexppart_b\romannumeral-`0#2% }% -\def\XINT_expr_scanfracpart_a #1% +\def\XINT_expr_scanexppart_b #1% {% - \ifcat #1\relax\else - \ifx !#1\else - \expandafter\expandafter\expandafter - \xint_thirdofthree - \fi\fi - \xint_firstoftwo !% this stops the scan - {\expandafter\XINT_expr_scanfracpart_aa\string }#1% + \ifcat \relax #1\xint_dothis{0!#1}\fi % stops the scan (incorrect syntax) + \ifcat a#1\xint_dothis{0!*#1}\fi % idem + \if +#1\xint_dothis {\XINT_expr_scanexppart_a +}\fi + \if -#1\xint_dothis {\XINT_expr_scanexppart_a -}\fi + \xint_orthat {\expandafter\XINT_expr_scanexppart_c\string #1}% }% -\def\XINT_expr_scanfracpart_aa #1% +\def\XINT_expr_scanexppart_c #1% {% \ifnum \xint_c_ix<1#1 - \expandafter\XINT_expr_scanfracpart_b + \expandafter\XINT_expr_scanexppart_d \else \expandafter !% \fi #1% }% -\def\XINT_expr_scanfracpart_b #1% +\def\XINT_expr_scanexppart_d #1#2% {% \expandafter #1\romannumeral-`0\expandafter - \XINT_expr_scanfracpart_a\romannumeral-`0\romannumeral-`0% + \XINT_expr_scanexppart_e\romannumeral-`0#2% +}% +\def\XINT_expr_scanexppart_e #1% +{% + \ifcat \relax #1\xint_dothis{!#1}\fi % stops the scan + \ifcat a#1\xint_dothis{!*#1}\fi % idem + \xint_orthat {\expandafter\XINT_expr_scanexppart_f\string #1}% +}% +\def\XINT_expr_scanexppart_f #1% +{% + \ifnum \xint_c_ix<1#1 + \expandafter\XINT_expr_scanexppart_d + \else + \expandafter !% + \fi + #1% }% \def\XINT_expr_scanhex_I #1% {% \expandafter\XINT_expr_getop\romannumeral-`0\expandafter - \XINT_expr_lock\expandafter\XINT_expr_inhex + \XINT_expr_lockscan\expandafter\XINT_expr_inhex \romannumeral-`0\XINT_expr_scanhexI_a }% \def\XINT_expr_inhex #1.#2#3;% expanded inside \csname..\endcsname @@ -346,13 +408,9 @@ }% \def\XINT_expr_scanhexI_a #1% {% - \ifcat #1\relax\else - \ifx !#1\else - \expandafter\expandafter\expandafter - \xint_thirdofthree - \fi\fi - \xint_firstoftwo {.I;!}% - {\expandafter\XINT_expr_scanhexI_aa\string }#1% + \ifcat #1\relax\xint_dothis{.I;!#1}\fi + \ifx !#1\xint_dothis{.I;!*!}\fi % tacit multiplication + \xint_orthat {\expandafter\XINT_expr_scanhexI_aa\string #1}% }% \def\XINT_expr_scanhexI_aa #1% {% @@ -373,25 +431,21 @@ \fi #1% }% -\def\XINT_expr_scanhexI_b #1% +\def\XINT_expr_scanhexI_b #1#2% {% \expandafter #1\romannumeral-`0\expandafter - \XINT_expr_scanhexI_a\romannumeral-`0\romannumeral-`0% + \XINT_expr_scanhexI_a\romannumeral-`0#2% }% -\def\XINT_expr_scanhex_transition .% +\def\XINT_expr_scanhex_transition .#1% {% \expandafter.\expandafter.\romannumeral-`0\expandafter - \XINT_expr_scanhexII_a\romannumeral-`0\romannumeral-`0% + \XINT_expr_scanhexII_a\romannumeral-`0#1% }% \def\XINT_expr_scanhexII_a #1% {% - \ifcat #1\relax\else - \ifx !#1\else - \expandafter\expandafter\expandafter - \xint_thirdofthree - \fi\fi - \xint_firstoftwo {;!}% this stops the scan - {\expandafter\XINT_expr_scanhexII_aa\string }#1% + \ifcat #1\relax\xint_dothis{;!#1}\fi + \ifx !#1\xint_dothis{;!*!}\fi % tacit multiplication + \xint_orthat {\expandafter\XINT_expr_scanhexII_aa\string #1}% }% \def\XINT_expr_scanhexII_aa #1% {% @@ -406,47 +460,104 @@ \fi #1% }% -\def\XINT_expr_scanhexII_b #1% +\def\XINT_expr_scanhexII_b #1#2% {% \expandafter #1\romannumeral-`0\expandafter - \XINT_expr_scanhexII_a\romannumeral-`0\romannumeral-`0% + \XINT_expr_scanhexII_a\romannumeral-`0#2% +}% +\def\XINT_expr_scanfunc +{% + \expandafter\XINT_expr_func\romannumeral-`0\XINT_expr_scanfunc_a +}% +\def\XINT_expr_scanfunc_a #1#2% +{% + \expandafter #1\romannumeral-`0\expandafter\XINT_expr_scanfunc_b\romannumeral-`0#2% +}% +\def\XINT_expr_scanfunc_b #1% +{% + \ifx !#1\xint_dothis{\xint_firstoftwo{(_*!}}\fi + \ifcat \relax#1\xint_dothis{(_}\fi + \if (#1\xint_dothis{\xint_firstoftwo{(`}}\fi + \if _#1\xint_dothis \XINT_expr_scanfunc_a \fi + \if @#1\xint_dothis \XINT_expr_scanfunc_a \fi + \ifnum \xint_c_ix<1\string#1 \xint_dothis \XINT_expr_scanfunc_a \fi + \ifcat a#1\xint_dothis \XINT_expr_scanfunc_a \fi + \xint_orthat {(_}% + #1% }% -\def\XINT_expr_getop #1% this #1 is the current locked computed value -{% full expansion of next token, first swallowing a possible space - \expandafter\XINT_expr_getop_a\expandafter #1% - \romannumeral-`0\romannumeral-`0% +\def\XINT_expr_func #1(#2% +{% #2=` pour une fonction, #2=_ pour une variable + \if #2`\ifcsname XINT_expr_var_#1\endcsname + \expandafter\expandafter\expandafter\xint_thirdofthree + \fi\fi + \xint_firstoftwo {\xint_c_xviii #2{#1}}{\xint_c_xviii _{#1}*(}% }% +\def\XINT_expr_getop #1#2% this #1 is the current locked computed value +{% + \expandafter\XINT_expr_getop_a\expandafter #1\romannumeral-`0#2% +}% +\catcode`* 11 \def\XINT_expr_getop_a #1#2% -{% if a control sequence is found, must be either \relax or register|variable - \ifcat #2\relax\expandafter\xint_firstoftwo - \else \expandafter\xint_secondoftwo - \fi - {\ifx #2\relax\expandafter\xint_firstofthree - \else\expandafter\xint_secondofthree % tacit multiplication - \fi }% - {\ifx !#2\expandafter\xint_secondofthree % tacit multiplication - \else % 1.09k adds tacit multiplication in front of ( - \if (#2\expandafter\expandafter\expandafter\xint_secondofthree - \else - \expandafter\expandafter\expandafter\xint_thirdofthree - \fi - \fi }% +{% + \ifx \relax #2\xint_dothis\xint_firstofthree\fi + \ifcat \relax #2\xint_dothis\xint_secondofthree\fi + \if _#2\xint_dothis \xint_secondofthree\fi + \if @#2\xint_dothis \xint_secondofthree\fi + \if (#2\xint_dothis \xint_secondofthree\fi + \ifx !#2\xint_dothis \xint_secondofthree\fi + \xint_orthat \xint_thirdofthree {\XINT_expr_foundend #1}% - {\XINT_expr_foundop *#1#2}% - {\XINT_expr_foundop #2#1}% + {\XINT_expr_precedence_* *#1#2}% tacit multiplication + {\XINT_expr_getop_b #2#1}% }% +\catcode`* 12 \def\XINT_expr_foundend {\xint_c_ \relax }% \relax is a place holder here. -\def\XINT_expr_foundop #1% then becomes and is followed by <\.=f> -{% 1.09a: no control sequence \XINT_expr_op_#1, code common to expr/flexpr +\def\XINT_expr_getop_b #1% +{% ? and : a special syntax in \xintexpr as they are + % followed by braced arguments, and thus we must intercept them here. + % I wanted to change this but now I don't have time to think about it. + % 1.1 removes : as logic operator. Replaced by ??. + \if '#1\xint_dothis{\XINT_expr_binopwrd }\fi + \if ?#1\xint_dothis{\XINT_expr_precedence_? ?}\fi + \xint_orthat {\XINT_expr_scanop_a #1}% +}% +\def\XINT_expr_binopwrd #1#2'{\expandafter\XINT_expr_foundop_a + \csname XINT_expr_itself_\xint_zapspaces #2 \xint_bye\xint_bye\endcsname #1}% +\def\XINT_expr_scanop_a #1#2#3% + {\expandafter\XINT_expr_scanop_b\expandafter #1\expandafter #2\romannumeral-`0#3}% +\def\XINT_expr_scanop_b #1#2#3% +{% + \ifcat#3\relax\xint_dothis{\XINT_expr_foundop_a #1#2#3}\fi + \ifcsname XINT_expr_itself_#1#3\endcsname + \xint_dothis + {\expandafter\XINT_expr_scanop_c\csname XINT_expr_itself_#1#3\endcsname #2}\fi + \xint_orthat {\XINT_expr_foundop_a #1#2#3}% +}% +\def\XINT_expr_scanop_c #1#2#3% +{% + \expandafter\XINT_expr_scanop_d\expandafter #1\expandafter #2\romannumeral-`0#3% +}% +\def\XINT_expr_scanop_d #1#2#3% +{% + \ifcat#3\relax \xint_dothis{\XINT_expr_foundop #1#2#3}\fi + \ifcsname XINT_expr_itself_#1#3\endcsname + \xint_dothis + {\expandafter\XINT_expr_scanop_c\csname XINT_expr_itself_#1#3\endcsname #2}\fi + \xint_orthat {\csname XINT_expr_precedence_#1\endcsname #1#2#3}% +}% +\def\XINT_expr_foundop_a #1% +{% \ifcsname XINT_expr_precedence_#1\endcsname - \expandafter\xint_afterfi\expandafter - {\csname XINT_expr_precedence_#1\endcsname #1}% + \csname XINT_expr_precedence_#1\expandafter\endcsname + \expandafter #1% \else - \XINT_expr_unexpectedtoken - \expandafter\XINT_expr_getop + \xint_afterfi{\XINT_expr_unknown_operator {#1}\XINT_expr_getop}% \fi }% -\def\XINT_tmpa #1#2#3#4#5% +\def\XINT_expr_unknown_operator #1{\xintError:removed \xint_gobble_i {#1}}% +\def\XINT_expr_foundop #1{\csname XINT_expr_precedence_#1\endcsname #1}% +\catcode`) 11 +\def\XINT_tmpa #1#2#3#4% (avant #4#5) {% \def#1##1% {% @@ -457,44 +568,46 @@ }% \def#2##1##2% {% - \ifcase ##1\expandafter #4% - \or\xint_afterfi{% - \XINT_expr_extra_closing_paren - \expandafter #1\romannumeral-`0\XINT_expr_getop - }% + \ifcase ##1\xint_afterfi + {\ifx\XINT_expr_itself_^C ##2\xint_dothis + {\expandafter#1\romannumeral-`0\expandafter\XINT_expr_getnext\xint_gobble_i}\fi + \xint_orthat \XINT_expr_done }% + \or\xint_afterfi{\XINT_expr_extra_) + \expandafter #1\romannumeral-`0\XINT_expr_getop }% \else - \xint_afterfi{\expandafter#1\romannumeral-`0\csname XINT_#5_op_##2\endcsname }% + \xint_afterfi{\expandafter#1\romannumeral-`0\csname XINT_#4_op_##2\endcsname }% \fi }% }% +\def\XINT_expr_extra_) {\xintError:removed }% \xintFor #1 in {expr,flexpr,iiexpr} \do {% -\expandafter\XINT_tmpa + \expandafter\XINT_tmpa \csname XINT_#1_until_end_a\expandafter\endcsname \csname XINT_#1_until_end_b\expandafter\endcsname - \csname XINT_#1_op_-vi\expandafter\endcsname - \csname XINT_#1_done\endcsname + \csname XINT_#1_op_-vi\endcsname {#1}% }% -\def\XINT_expr_extra_closing_paren {\xintError:removed }% \def\XINT_tmpa #1#2#3#4#5#6% {% - \def #1{\expandafter #3\romannumeral-`0\XINT_expr_getnext }% - \let #2#1% + \def #1##1{\expandafter #3\romannumeral-`0\XINT_expr_getnext }% + \def #2{\expandafter #3\romannumeral-`0\XINT_expr_getnext }% \def #3##1{\xint_UDsignfork ##1{\expandafter #3\romannumeral-`0#5}% -{#4##1}% \krof }% - \def #4##1##2% - {% - \ifcase ##1\expandafter \XINT_expr_missing_cparen - \or \expandafter \XINT_expr_getop - \else \xint_afterfi - {\expandafter #3\romannumeral-`0\csname XINT_#6_op_##2\endcsname }% - \fi + \def #4##1##2{\ifcase ##1% + \xint_afterfi{\ifx\XINT_expr_itself_^C ##2\xint_dothis{\xint_c_ ##2}\fi + \xint_orthat\XINT_expr_missing_) }% + \or \csname XINT_#6_op_##2\expandafter\endcsname + \else + \xint_afterfi{\expandafter #3\romannumeral-`0\csname XINT_#6_op_##2\endcsname }% + \fi }% }% +\def\XINT_expr_missing_) {\xintError:inserted \xint_c_ \XINT_expr_done }% +\catcode`) 12 \xintFor #1 in {expr,flexpr,iiexpr} \do {% -\expandafter\XINT_tmpa + \expandafter\XINT_tmpa \csname XINT_#1_op_(\expandafter\endcsname \csname XINT_#1_oparen\expandafter\endcsname \csname XINT_#1_until_)_a\expandafter\endcsname @@ -502,100 +615,529 @@ \csname XINT_#1_op_-vi\endcsname {#1}% }% -\def\XINT_expr_missing_cparen {\xintError:inserted \xint_c_ \XINT_expr_done }% -\expandafter\let\csname XINT_expr_precedence_)\endcsname \xint_c_i -\expandafter\let\csname XINT_flexpr_precedence_)\endcsname \xint_c_i -\expandafter\let\csname XINT_iiexpr_precedence_)\endcsname \xint_c_i -\expandafter\let\csname XINT_expr_op_)\endcsname \XINT_expr_getop -\expandafter\let\csname XINT_flexpr_op_)\endcsname\XINT_expr_getop -\expandafter\let\csname XINT_iiexpr_op_)\endcsname\XINT_expr_getop -\def\XINT_tmpb #1#2#3#4#5#6%#7% -{% - \expandafter\XINT_tmpc - \csname XINT_#1_op_#3\expandafter\endcsname - \csname XINT_#1_until_#3_a\expandafter\endcsname - \csname XINT_#1_until_#3_b\expandafter\endcsname - \csname XINT_#1_op_-#5\expandafter\endcsname - \csname xint_c_#4\expandafter\endcsname - \csname #2#6\expandafter\endcsname - \csname XINT_expr_precedence_#3\endcsname {#1}%{#7}% -}% -\def\XINT_tmpc #1#2#3#4#5#6#7#8#9% -{% - \def #1##1% \XINT_expr_op_ - {% keep value, get next number and operator, then do until - \expandafter #2\expandafter ##1% - \romannumeral-`0\expandafter\XINT_expr_getnext - }% - \def #2##1##2% \XINT_expr_until__a - {\xint_UDsignfork - ##2{\expandafter #2\expandafter ##1\romannumeral-`0#4}% - -{#3##1##2}% - \krof }% - \def #3##1##2##3##4% \XINT_expr_until__b - {% either execute next operation now, or first do next (possibly unary) - \ifnum ##2>#5% - \xint_afterfi {\expandafter #2\expandafter ##1\romannumeral-`0% - \csname XINT_#8_op_##3\endcsname {##4}}% - \else - \xint_afterfi - {\expandafter ##2\expandafter ##3% - \csname .=#6#9{\XINT_expr_unlock ##1}{\XINT_expr_unlock ##4}\endcsname }% - \fi - }% - \let #7#5% +\expandafter\let\csname XINT_expr_precedence_)\endcsname\xint_c_i +\expandafter\let\csname XINT_expr_precedence_]\endcsname\xint_c_i +\expandafter\let\csname XINT_expr_precedence_;\endcsname\xint_c_i +\let\XINT_expr_precedence_a \xint_c_xviii +\expandafter\let\csname XINT_expr_precedence_^C\endcsname \xint_c_ +\expandafter\let\csname XINT_expr_precedence_++)\endcsname \xint_c_i +\catcode`. 11 \catcode`= 11 \catcode`+ 11 +\xintFor #1 in {expr,flexpr,iiexpr} \do {% + \expandafter\let\csname XINT_#1_op_)\endcsname \XINT_expr_getop + \expandafter\let\csname XINT_#1_op_;\endcsname \space + \expandafter\def\csname XINT_#1_op_]\endcsname ##1{\XINT_expr_getop ##1a}% + \expandafter\let\csname XINT_#1_op_a\endcsname \XINT_expr_getop + \expandafter\def\csname XINT_#1_op_++)\endcsname ##1##2\relax + {\expandafter\XINT_expr_foundend \expandafter + {\expandafter\.=+\xintiCeil{\XINT_expr_unlock ##1}}}% +}% +\catcode`. 12 \catcode`= 12 \catcode`+ 12 +\xintFor* #1 in {{==}{<=}{>=}{!=}{&&}{||}{**}{//}{/:}{..}{..[}{].}{]..}% + {+[}{-[}{*[}{/[}{**[}{^[}{a+}{a-}{a*}{a/}{a**}{a^}% + {][}{][:}{:]}{^C}{++}{++)}} + \do {\expandafter\def\csname XINT_expr_itself_#1\endcsname {#1}}% +\def\XINT_tmpc #1#2#3#4#5#6#7#8% +{% + \def #1##1% \XINT_expr_op_ ou flexpr ou iiexpr + {% keep value, get next number and operator, then do until + \expandafter #2\expandafter ##1% + \romannumeral-`0\expandafter\XINT_expr_getnext }% + \def #2##1##2% \XINT_expr_until__a ou flexpr ou iiexpr + {\xint_UDsignfork ##2{\expandafter #2\expandafter ##1\romannumeral-`0#4}% + -{#3##1##2}% + \krof }% + \def #3##1##2##3##4% \XINT_expr_until__b ou flexpr ou iiexpr + {% either execute next operation now, or first do next (possibly unary) + \ifnum ##2>#5% + \xint_afterfi {\expandafter #2\expandafter ##1\romannumeral-`0% + \csname XINT_#8_op_##3\endcsname {##4}}% + \else \xint_afterfi {\expandafter ##2\expandafter ##3% + \csname .=#6{\XINT_expr_unlock ##1}{\XINT_expr_unlock ##4}\endcsname }% + \fi }% + \let #7#5% }% -\def\XINT_tmpa #1{\XINT_tmpb {expr}{xint}#1{}}% +\def\XINT_tmpb #1#2#3#4#5#6% +{% + \expandafter\XINT_tmpc + \csname XINT_#1_op_#3\expandafter\endcsname + \csname XINT_#1_until_#3_a\expandafter\endcsname + \csname XINT_#1_until_#3_b\expandafter\endcsname + \csname XINT_#1_op_-#5\expandafter\endcsname + \csname xint_c_#4\expandafter\endcsname + \csname #2#6\expandafter\endcsname + \csname XINT_expr_precedence_#3\endcsname {#1}% +}% +\xintFor #1 in {expr, flexpr, iiexpr} \do {% + \def\XINT_tmpa ##1{\XINT_tmpb {#1}{xint}##1}% + \xintApplyInline {\XINT_tmpa }{% + {|{iii}{vi}{OR}}% + {&{iv}{vi}{AND}}% + {{xor}{iii}{vi}{XOR}}% + {<{v}{vi}{Lt}}% + {>{v}{vi}{Gt}}% + {={v}{vi}{Eq}}% + {{<=}{v}{vi}{LtorEq}}% + {{>=}{v}{vi}{GtorEq}}% + {{!=}{v}{vi}{Neq}}% + {{..}{iii}{vi}{Seq::csv}}% will get redefined to use \xintiiSeq::csv in xintiiexpr + {{//}{vii}{vii}{DivTrunc}}% will get redefined for xintiiexpr + {{/:}{vii}{vii}{Mod}}% + }% +}% +\def\XINT_tmpa #1{\XINT_tmpb {expr}{xint}#1}% \xintApplyInline {\XINT_tmpa }{% - {|{iii}{vi}{OR}}% - {&{iv}{vi}{AND}}% - {<{v}{vi}{Lt}}% - {>{v}{vi}{Gt}}% - {={v}{vi}{Eq}}% {+{vi}{vi}{Add}}% {-{vi}{vi}{Sub}}% {*{vii}{vii}{Mul}}% {/{vii}{vii}{Div}}% {^{viii}{viii}{Pow}}% - {e{ix}{ix}{fE}}% - {E{ix}{ix}{fE}}% + {{..[}{iii}{vi}{SeqA::csv}}% + {{]..}{iii}{vi}{SeqB::csv}}% }% -\def\XINT_tmpa #1{\XINT_tmpb {flexpr}{xint}#1{}}% -\xintApplyInline {\XINT_tmpa }{% - {|{iii}{vi}{OR}}% - {&{iv}{vi}{AND}}% - {<{v}{vi}{Lt}}% - {>{v}{vi}{Gt}}% - {={v}{vi}{Eq}}% -}% -\def\XINT_tmpa #1{\XINT_tmpb {flexpr}{XINTinFloat}#1{[\XINTdigits]}}% +\def\XINT_tmpa #1{\XINT_tmpb {flexpr}{XINTinFloat}#1}% \xintApplyInline {\XINT_tmpa }{% {+{vi}{vi}{Add}}% {-{vi}{vi}{Sub}}% {*{vii}{vii}{Mul}}% {/{vii}{vii}{Div}}% {^{viii}{viii}{Power}}% - {e{ix}{ix}{fE}}% - {E{ix}{ix}{fE}}% + {{..[}{iii}{vi}{SeqA::csv}}% + {{]..}{iii}{vi}{SeqB::csv}}% }% -\def\XINT_tmpa #1{\XINT_tmpb {iiexpr}{xint}#1{}}% +\def\XINT_tmpa #1{\XINT_tmpb {iiexpr}{xint}#1}% \xintApplyInline {\XINT_tmpa }{% - {|{iii}{vi}{OR}}% - {&{iv}{vi}{AND}}% - {<{v}{vi}{Lt}}% - {>{v}{vi}{Gt}}% - {={v}{vi}{Eq}}% {+{vi}{vi}{iiAdd}}% {-{vi}{vi}{iiSub}}% {*{vii}{vii}{iiMul}}% - {/{vii}{vii}{iiQuo}}% + {/{vii}{vii}{iiDivRound}}% CHANGED IN 1.1! PREVIOUSLY DID EUCLIDEAN QUOTIENT {^{viii}{viii}{iiPow}}% - {e{ix}{ix}{iE}}% - {E{ix}{ix}{iE}}% + {{..[}{iii}{vi}{iiSeqA::csv}}% + {{]..}{iii}{vi}{iiSeqB::csv}}% + {{..}{iii}{vi}{iiSeq::csv}}% + {{//}{vii}{vii}{iiDivTrunc}}% + {{/:}{vii}{vii}{iiMod}}% +}% +\def\XINT_expr_binop_inline_a + {\expandafter\xint_gobble_i\romannumeral-`0\XINT_expr_binop_inline_b }% +\def\XINT_expr_binop_inline_b #1#2,{\XINT_expr_binop_inline_c #2,{#1}}% +\def\XINT_expr_binop_inline_c #1{% + \if ,#1\xint_dothis\XINT_expr_binop_inline_e\fi + \if ^#1\xint_dothis\XINT_expr_binop_inline_end\fi + \xint_orthat\XINT_expr_binop_inline_d #1}% +\def\XINT_expr_binop_inline_d #1,#2{,#2{#1}\XINT_expr_binop_inline_b {#2}}% +\def\XINT_expr_binop_inline_e #1,#2{,\XINT_expr_binop_inline_b {#2}}% +\def\XINT_expr_binop_inline_end #1,#2{}% +\def\XINT_tmpc #1#2#3#4#5#6#7#8% +{% + \def #1##1% \XINT_expr_op_ ou flexpr ou iiexpr + {% keep value, get next number and operator, then do until + \expandafter #2\expandafter ##1% + \romannumeral-`0\expandafter\XINT_expr_getnext }% + \def #2##1##2% \XINT_expr_until__a ou flexpr ou iiexpr + {\xint_UDsignfork ##2{\expandafter #2\expandafter ##1\romannumeral-`0#4}% + -{#3##1##2}% + \krof }% + \def #3##1##2##3##4% \XINT_expr_until__b ou flexpr ou iiexpr + {% either execute next operation now, or first do next (possibly unary) + \ifnum ##2>#5% + \xint_afterfi {\expandafter #2\expandafter ##1\romannumeral-`0% + \csname XINT_#8_op_##3\endcsname {##4}}% + \else \xint_afterfi {\expandafter ##2\expandafter ##3% + \csname .=\expandafter\XINT_expr_binop_inline_a\expandafter + {\expandafter\expandafter\expandafter#6\expandafter + \xint_exchangetwo_keepbraces\expandafter + {\expandafter\XINT_expr_unlock\expandafter ##4\expandafter}\expandafter}% + \romannumeral-`0\XINT_expr_unlock ##1,^,\endcsname }% + \fi }% + \let #7#5% +}% +\def\XINT_tmpb #1#2#3#4% +{% + \expandafter\XINT_tmpc + \csname XINT_#1_op_#2\expandafter\endcsname + \csname XINT_#1_until_#2_a\expandafter\endcsname + \csname XINT_#1_until_#2_b\expandafter\endcsname + \csname XINT_#1_op_-#3\expandafter\endcsname + \csname xint_c_#3\expandafter\endcsname + \csname #4\expandafter\endcsname + \csname XINT_expr_precedence_#2\endcsname {#1}% +}% +\xintApplyInline {\expandafter\XINT_tmpb \xint_firstofone}{% + {{expr}{a+}{vi}{xintAdd}}% + {{expr}{a-}{vi}{xintSub}}% + {{expr}{a*}{vii}{xintMul}}% + {{expr}{a/}{vii}{xintDiv}}% + {{expr}{a^}{viii}{xintPow}}% + {{iiexpr}{a+}{vi}{xintiiAdd}}% + {{iiexpr}{a-}{vi}{xintiiSub}}% + {{iiexpr}{a*}{vii}{xintiiMul}}% + {{iiexpr}{a/}{vii}{xintiiDivRound}}% + {{iiexpr}{a^}{viii}{xintiiPow}}% + {{flexpr}{a+}{vi}{XINTinFloatAdd}}% + {{flexpr}{a-}{vi}{XINTinFloatSub}}% + {{flexpr}{a*}{vii}{XINTinFloatMul}}% + {{flexpr}{a/}{vii}{XINTinFloatDiv}}% + {{flexpr}{a^}{viii}{XINTinFloatPower}}% +}% +\def\XINT_tmpc #1#2#3#4#5#6#7% +{% + \def #1##1{\expandafter#2\expandafter##1\romannumeral-`0% + \expandafter #3\romannumeral-`0\XINT_expr_getnext }% + \def #2##1##2##3##4% + {% either execute next operation now, or first do next (possibly unary) + \ifnum ##2>#4% + \xint_afterfi {\expandafter #2\expandafter ##1\romannumeral-`0% + \csname XINT_#7_op_##3\endcsname {##4}}% + \else \xint_afterfi {\expandafter ##2\expandafter ##3% + \csname .=\expandafter\XINT_expr_binop_inline_a\expandafter + {\expandafter#5\expandafter + {\expandafter\XINT_expr_unlock\expandafter ##1\expandafter}\expandafter}% + \romannumeral-`0\XINT_expr_unlock ##4,^,\endcsname }% + \fi }% + \let #6#4% +}% +\def\XINT_tmpb #1#2#3#4% +{% + \expandafter\XINT_tmpc + \csname XINT_#1_op_#2\expandafter\endcsname + \csname XINT_#1_until_#2\expandafter\endcsname + \csname XINT_#1_until_)_a\expandafter\endcsname + \csname xint_c_#3\expandafter\endcsname + \csname #4\expandafter\endcsname + \csname XINT_expr_precedence_#2\endcsname {#1}% +}% +\xintApplyInline {\expandafter\XINT_tmpb\xint_firstofone }{% + {{expr}{+[}{vi}{xintAdd}}% + {{expr}{-[}{vi}{xintSub}}% + {{expr}{*[}{vii}{xintMul}}% + {{expr}{/[}{vii}{xintDiv}}% + {{expr}{^[}{viii}{xintPow}}% + {{iiexpr}{+[}{vi}{xintiiAdd}}% + {{iiexpr}{-[}{vi}{xintiiSub}}% + {{iiexpr}{*[}{vii}{xintiiMul}}% + {{iiexpr}{/[}{vii}{xintiiDivRound}}% + {{iiexpr}{^[}{viii}{xintiiPow}}% + {{flexpr}{+[}{vi}{XINTinFloatAdd}}% + {{flexpr}{-[}{vi}{XINTinFloatSub}}% + {{flexpr}{*[}{vii}{XINTinFloatMul}}% + {{flexpr}{/[}{vii}{XINTinFloatDiv}}% + {{flexpr}{^[}{viii}{XINTinFloatPower}}% +}% +\xintFor #1 in {and,or,xor,mod} \do {% + \expandafter\def\csname XINT_expr_itself_#1\endcsname {#1}}% +\expandafter\let\csname XINT_expr_precedence_and\expandafter\endcsname + \csname XINT_expr_precedence_&\endcsname +\expandafter\let\csname XINT_expr_precedence_or\expandafter\endcsname + \csname XINT_expr_precedence_|\endcsname +\expandafter\let\csname XINT_expr_precedence_mod\expandafter\endcsname + \csname XINT_expr_precedence_/:\endcsname +\xintFor #1 in {expr, flexpr, iiexpr} \do {% + \expandafter\let\csname XINT_#1_op_and\expandafter\endcsname + \csname XINT_#1_op_&\endcsname + \expandafter\let\csname XINT_#1_op_or\expandafter\endcsname + \csname XINT_#1_op_|\endcsname + \expandafter\let\csname XINT_#1_op_mod\expandafter\endcsname + \csname XINT_#1_op_/:\endcsname +}% +\expandafter\let\csname XINT_expr_precedence_==\expandafter\endcsname + \csname XINT_expr_precedence_=\endcsname +\expandafter\let\csname XINT_expr_precedence_&&\expandafter\endcsname + \csname XINT_expr_precedence_&\endcsname +\expandafter\let\csname XINT_expr_precedence_||\expandafter\endcsname + \csname XINT_expr_precedence_|\endcsname +\expandafter\let\csname XINT_expr_precedence_**\expandafter\endcsname + \csname XINT_expr_precedence_^\endcsname +\expandafter\let\csname XINT_expr_precedence_a**\expandafter\endcsname + \csname XINT_expr_precedence_a^\endcsname +\expandafter\let\csname XINT_expr_precedence_**[\expandafter\endcsname + \csname XINT_expr_precedence_^[\endcsname +\xintFor #1 in {expr, flexpr, iiexpr} \do {% + \expandafter\let\csname XINT_#1_op_==\expandafter\endcsname + \csname XINT_#1_op_=\endcsname + \expandafter\let\csname XINT_#1_op_&&\expandafter\endcsname + \csname XINT_#1_op_&\endcsname + \expandafter\let\csname XINT_#1_op_||\expandafter\endcsname + \csname XINT_#1_op_|\endcsname + \expandafter\let\csname XINT_#1_op_**\expandafter\endcsname + \csname XINT_#1_op_^\endcsname + \expandafter\let\csname XINT_#1_op_a**\expandafter\endcsname + \csname XINT_#1_op_a^\endcsname + \expandafter\let\csname XINT_#1_op_**[\expandafter\endcsname + \csname XINT_#1_op_^[\endcsname }% \def\XINT_tmpa #1#2#3#4#5#6% {% - \def #1##1% \XINT_expr_op_,_a + \def #1##1% \XINT_expr_op_][ + {% + \expandafter #2\expandafter ##1\romannumeral-`0\XINT_expr_getnext + }% + \def #2##1##2% \XINT_expr_until_][_a + {\xint_UDsignfork + ##2{\expandafter #2\expandafter ##1\romannumeral-`0#4}% + -{#3##1##2}% + \krof }% + \def #3##1##2##3##4% \XINT_expr_until_][_b + {% + \ifnum ##2>\xint_c_ii + \xint_afterfi {\expandafter #2\expandafter ##1\romannumeral-`0% + \csname XINT_#6_op_##3\endcsname {##4}}% + \else + \xint_afterfi + {\expandafter ##2\expandafter ##3\csname + .=\expandafter\xintListSel:csv \romannumeral-`0\XINT_expr_unlock ##4;% + \XINT_expr_unlock ##1;\endcsname % unlock for \xintNewExpr + }% + \fi + }% + \let #5\xint_c_ii +}% +\xintFor #1 in {expr,flexpr,iiexpr} \do {% +\expandafter\XINT_tmpa + \csname XINT_#1_op_][\expandafter\endcsname + \csname XINT_#1_until_][_a\expandafter\endcsname + \csname XINT_#1_until_][_b\expandafter\endcsname + \csname XINT_#1_op_-vi\expandafter\endcsname + \csname XINT_expr_precedence_][\endcsname {#1}% +}% +\def\XINT_tmpa #1#2#3#4#5#6% +{% + \def #1##1% \XINT_expr_op_: + {% + \expandafter #2\expandafter ##1\romannumeral-`0\XINT_expr_getnext + }% + \def #2##1##2% \XINT_expr_until_:_a + {\xint_UDsignfork + ##2{\expandafter #2\expandafter ##1\romannumeral-`0#4}% + -{#3##1##2}% + \krof }% + \def #3##1##2##3##4% \XINT_expr_until_:_b + {% + \ifnum ##2>\xint_c_iii + \xint_afterfi {\expandafter #2\expandafter ##1\romannumeral-`0% + \csname XINT_#6_op_##3\endcsname {##4}}% + \else + \xint_afterfi + {\expandafter ##2\expandafter ##3\csname + .=:\xintiiifSgn{\XINT_expr_unlock ##1}NPP.% : and dots for expansion + \xintiiifSgn{\XINT_expr_unlock ##4}NPP.% in \xintNewExpr context + \xintNum{\XINT_expr_unlock ##1};\xintNum{\XINT_expr_unlock ##4}\endcsname + }% + \fi + }% + \let #5\xint_c_iii +}% +\xintFor #1 in {expr,flexpr,iiexpr} \do {% +\expandafter\XINT_tmpa + \csname XINT_#1_op_:\expandafter\endcsname + \csname XINT_#1_until_:_a\expandafter\endcsname + \csname XINT_#1_until_:_b\expandafter\endcsname + \csname XINT_#1_op_-vi\expandafter\endcsname + \csname XINT_expr_precedence_:\endcsname {#1}% +}% +\catcode`[ 11 \catcode`] 11 +\let\XINT_expr_precedence_:] \xint_c_iii +\def\XINT_expr_op_:] #1{\expandafter\xint_c_i\expandafter )% + \csname .=]\xintiiifSgn{\XINT_expr_unlock #1}npp\XINT_expr_unlock #1\endcsname }% +\let\XINT_flexpr_op_:] \XINT_expr_op_:] +\let\XINT_iiexpr_op_:] \XINT_expr_op_:] +\let\XINT_expr_precedence_][: \xint_c_iii +\edef\XINT_expr_op_][: #1{\xint_c_ii \expandafter\noexpand + \csname XINT_expr_itself_][\endcsname #10\string :}% +\let\XINT_flexpr_op_][: \XINT_expr_op_][: +\let\XINT_iiexpr_op_][: \XINT_expr_op_][: +\catcode`[ 12 \catcode`] 12 +\def\xintListSel:csv #1{% these complications are due to \xintNewExpr matters + \if ]\noexpand#1\xint_dothis{\expandafter\XINT_listsel:_s\romannumeral-`0}\fi + \if :\noexpand#1\xint_dothis{\XINT_listsel:_:}\fi + \xint_orthat {\XINT_listsel:_nth #1}% +}% +\def\XINT_listsel:_s #1{\if p#1\expandafter\XINT_listsel:_trim\else + \expandafter\XINT_listsel:_keep\fi }% +\def\XINT_listsel:_: #1.#2.{\csname XINT_listsel:_#1#2\endcsname }% +\def\XINT_listsel:_trim #1;#2;% + {\xintListWithSep,{\xintTrim {\xintNum{#1}}{\xintCSVtoListNonStripped{#2}}}}% +\def\XINT_listsel:_keep #1;#2;% + {\xintListWithSep,{\xintKeep {\xintNum{#1}}{\xintCSVtoListNonStripped{#2}}}}% +\def\XINT_listsel:_nth#1;#2;% + {\xintNthElt {\xintNum{#1}}{\xintCSVtoListNonStripped{#2}}}% +\def\XINT_listsel:_PP #1;#2;#3;% + {\xintListWithSep,% + {\xintTrim {\xintNum{#1}}% + {\xintKeep {\xintNum{#2}}% + {\xintCSVtoListNonStripped{#3}}% + }% + }% + }% +\def\XINT_listsel:_NN #1;#2;#3;% + {\xintListWithSep,% + {\xintTrim {\xintNum{#2}}% + {\xintKeep {\xintNum{#1}}% + {\xintCSVtoListNonStripped{#3}}% + }% + }% + }% +\def\XINT_listsel:_NP #1;#2;#3;% + {\expandafter\XINT_listsel:_NP_a \the\numexpr #1+% + \xintNthElt{0}{\xintCSVtoListNonStripped{#3}};#2;#3;}% +\def\XINT_listsel:_NP_a #1#2;{\if -#1\expandafter\XINT_listsel:_OP\fi + \XINT_listsel:_PP #1#2;}% +\def\XINT_listsel:_OP\XINT_listsel:_PP #1;{\XINT_listsel:_PP 0;}% +\def\XINT_listsel:_PN #1;#2;#3;% + {\expandafter\XINT_listsel:_PN_a \the\numexpr #2+% + \xintNthElt{0}{\xintCSVtoListNonStripped{#3}};#1;#3;}% +\def\XINT_listsel:_PN_a #1#2;#3;{\if -#1\expandafter\XINT_listsel:_PO\fi + \XINT_listsel:_PP #3;#1#2;}% +\def\XINT_listsel:_PO\XINT_listsel:_PP #1;#2;{\XINT_listsel:_PP #1;0;}% +\def\xintSeq::csv {\romannumeral0\xintseq::csv }% +\def\xintseq::csv #1#2% +{% + \expandafter\XINT_seq::csv\expandafter + {\the\numexpr \xintiCeil{#1}\expandafter}\expandafter + {\the\numexpr \xintiFloor{#2}}% +}% +\def\XINT_seq::csv #1#2% +{% + \ifcase\ifnum #1=#2 0\else\ifnum #2>#1 1\else -1\fi\fi\space + \expandafter\XINT_seq::csv_z + \or + \expandafter\XINT_seq::csv_p + \else + \expandafter\XINT_seq::csv_n + \fi + {#2}{#1}% +}% +\def\XINT_seq::csv_z #1#2{ #1/1[0]}% +\def\XINT_seq::csv_p #1#2% +{% + \ifnum #1>#2 + \expandafter\expandafter\expandafter\XINT_seq::csv_p + \else + \expandafter\XINT_seq::csv_e + \fi + \expandafter{\the\numexpr #1-\xint_c_i}{#2},#1/1[0]% +}% +\def\XINT_seq::csv_n #1#2% +{% + \ifnum #1<#2 + \expandafter\expandafter\expandafter\XINT_seq::csv_n + \else + \expandafter\XINT_seq::csv_e + \fi + \expandafter{\the\numexpr #1+\xint_c_i}{#2},#1/1[0]% +}% +\def\XINT_seq::csv_e #1,{ }% +\def\xintiiSeq::csv {\romannumeral0\xintiiseq::csv }% +\def\xintiiseq::csv #1#2% +{% + \expandafter\XINT_iiseq::csv\expandafter + {\the\numexpr #1\expandafter}\expandafter{\the\numexpr #2}% +}% +\def\XINT_iiseq::csv #1#2% +{% + \ifcase\ifnum #1=#2 0\else\ifnum #2>#1 1\else -1\fi\fi\space + \expandafter\XINT_iiseq::csv_z + \or + \expandafter\XINT_iiseq::csv_p + \else + \expandafter\XINT_iiseq::csv_n + \fi + {#2}{#1}% +}% +\def\XINT_iiseq::csv_z #1#2{ #1}% +\def\XINT_iiseq::csv_p #1#2% +{% + \ifnum #1>#2 + \expandafter\expandafter\expandafter\XINT_iiseq::csv_p + \else + \expandafter\XINT_seq::csv_e + \fi + \expandafter{\the\numexpr #1-\xint_c_i}{#2},#1% +}% +\def\XINT_iiseq::csv_n #1#2% +{% + \ifnum #1<#2 + \expandafter\expandafter\expandafter\XINT_iiseq::csv_n + \else + \expandafter\XINT_seq::csv_e + \fi + \expandafter{\the\numexpr #1+\xint_c_i}{#2},#1% +}% +\def\XINT_seq::csv_e #1,{ }% +\def\xintSeqA::csv #1% + {\expandafter\XINT_seqa::csv\expandafter{\romannumeral0\xintraw {#1}}}% +\def\XINT_seqa::csv #1#2{\expandafter\XINT_seqa::csv_a \romannumeral0\xintraw {#2};#1;}% +\def\xintiiSeqA::csv #1#2{\XINT_iiseqa::csv #1#2}% +\def\XINT_iiseqa::csv #1#2#3#4{\expandafter\XINT_seqa::csv_a + \romannumeral-`0\expandafter \XINT_expr_unlock\expandafter#4% + \expandafter;\romannumeral-`0\XINT_expr_unlock #2;}% +\def\XINTinFloatSeqA::csv #1{\expandafter\XINT_flseqa::csv\expandafter + {\romannumeral0\XINTinfloat [\XINTdigits]{#1}}}% +\def\XINT_flseqa::csv #1#2% + {\expandafter\XINT_seqa::csv_a\romannumeral0\XINTinfloat [\XINTdigits]{#2};#1;}% +\def\XINT_seqa::csv_a #1{\xint_UDzerominusfork + #1-{z}% + 0#1{n}% + 0-{p}% + \krof #1}% +\def\xintSeqB::csv #1#2% + {\expandafter\XINT_seqb::csv \expandafter{\romannumeral0\xintraw{#2}}{#1}}% +\def\XINT_seqb::csv #1#2{\expandafter\XINT_seqb::csv_a\romannumeral-`0#2#1!}% +\def\XINT_seqb::csv_a #1#2;#3;#4!{\expandafter\XINT_expr_seq_empty? + \romannumeral0\csname XINT_seqb::csv_#1\endcsname {#3}{#4}{#2}}% +\def\XINT_seqb::csv_p #1#2#3% +{% + \xintifCmp {#1}{#2}{,#1\expandafter\XINT_seqb::csv_p\expandafter}% + {,#1\xint_gobble_iii}{\xint_gobble_iii}% + {\romannumeral0\xintadd {#3}{#1}}{#2}{#3}% +}% +\def\XINT_seqb::csv_n #1#2#3% +{% + \xintifCmp {#1}{#2}{\xint_gobble_iii}{,#1\xint_gobble_iii}% + {,#1\expandafter\XINT_seqb::csv_n\expandafter}% + {\romannumeral0\xintadd {#3}{#1}}{#2}{#3}% +}% +\def\XINT_seqb::csv_z #1#2#3{,#1}% +\def\xintiiSeqB::csv #1#2{\XINT_iiseqb::csv #1#2}% +\def\XINT_iiseqb::csv #1#2#3#4% + {\expandafter\XINT_iiseqb::csv_a + \romannumeral-`0\expandafter \XINT_expr_unlock\expandafter#2% + \romannumeral-`0\XINT_expr_unlock #4!}% +\def\XINT_iiseqb::csv_a #1#2;#3;#4!{\expandafter\XINT_expr_seq_empty? + \romannumeral-`0\csname XINT_iiseqb::csv_#1\endcsname {#3}{#4}{#2}}% +\def\XINT_iiseqb::csv_p #1#2#3% +{% + \xintSgnFork{\XINT_Cmp {#1}{#2}}{,#1\expandafter\XINT_iiseqb::csv_p\expandafter}% + {,#1\xint_gobble_iii}{\xint_gobble_iii}% + {\romannumeral0\xintiiadd {#3}{#1}}{#2}{#3}% +}% +\def\XINT_iiseqb::csv_n #1#2#3% +{% + \xintSgnFork{\XINT_Cmp {#1}{#2}}{\xint_gobble_iii}{,#1\xint_gobble_iii}% + {,#1\expandafter\XINT_iiseqb::csv_n\expandafter}% + {\romannumeral0\xintiiadd {#3}{#1}}{#2}{#3}% +}% +\def\XINT_iiseqb::csv_z #1#2#3{,#1}% +\def\XINTinFloatSeqB::csv #1#2{\expandafter\XINT_flseqb::csv \expandafter + {\romannumeral0\XINTinfloat [\XINTdigits]{#2}}{#1}}% +\def\XINT_flseqb::csv #1#2{\expandafter\XINT_flseqb::csv_a\romannumeral-`0#2#1!}% +\def\XINT_flseqb::csv_a #1#2;#3;#4!{\expandafter\XINT_expr_seq_empty? + \romannumeral-`0\csname XINT_flseqb::csv_#1\endcsname {#3}{#4}{#2}}% +\def\XINT_flseqb::csv_p #1#2#3% +{% + \xintifCmp {#1}{#2}{,#1\expandafter\XINT_flseqb::csv_p\expandafter}% + {,#1\xint_gobble_iii}{\xint_gobble_iii}% + {\romannumeral0\XINTinfloatadd {#3}{#1}}{#2}{#3}% +}% +\def\XINT_flseqb::csv_n #1#2#3% +{% + \xintifCmp {#1}{#2}{\xint_gobble_iii}{,#1\xint_gobble_iii}% + {,#1\expandafter\XINT_flseqb::csv_n\expandafter}% + {\romannumeral0\XINTinfloatadd {#3}{#1}}{#2}{#3}% +}% +\def\XINT_flseqb::csv_z #1#2#3{,#1}% +\def\XINT_tmpa #1#2#3#4#5#6% +{% + \def #1##1% \XINT_expr_op_, {% \expandafter #2\expandafter ##1\romannumeral-`0\XINT_expr_getnext }% @@ -659,172 +1201,614 @@ \xintApplyInline{\XINT_tmpa {flexpr}\xintOpp}{{vi}{vii}{viii}{ix}}% \xintApplyInline{\XINT_tmpa {iiexpr}\xintiiOpp}{{vi}{vii}{viii}{ix}}% \let\XINT_expr_precedence_? \xint_c_x -\def \XINT_expr_op_? #1#2#3% +\def\XINT_expr_op_? #1#2{\if ?#2\expandafter \XINT_expr_op_??\fi + \XINT_expr_op_?a #1{#2}}% +\def\XINT_expr_op_?a #1#2#3% {% - \xintifZero{\XINT_expr_unlock #1}% - {\XINT_expr_getnext #3}% - {\XINT_expr_getnext #2}% + \xintiiifNotZero{\XINT_expr_unlock #1}{\XINT_expr_getnext #2}{\XINT_expr_getnext #3}% }% \let\XINT_flexpr_op_?\XINT_expr_op_? \let\XINT_iiexpr_op_?\XINT_expr_op_? -\let\XINT_expr_precedence_: \xint_c_x -\def \XINT_expr_op_: #1#2#3#4% +\def\XINT_expr_op_?? #1#2#3#4#5#6% {% - \xintifSgn {\XINT_expr_unlock #1}% - {\XINT_expr_getnext #2}% - {\XINT_expr_getnext #3}% - {\XINT_expr_getnext #4}% + \xintiiifSgn {\XINT_expr_unlock #2}{\XINT_expr_getnext #4}{\XINT_expr_getnext #5}% + {\XINT_expr_getnext #6}% }% -\let\XINT_flexpr_op_:\XINT_expr_op_: -\let\XINT_iiexpr_op_:\XINT_expr_op_: \let\XINT_expr_precedence_! \xint_c_x \def\XINT_expr_op_! #1{\expandafter\XINT_expr_getop - \csname .=\xintFac{\XINT_expr_unlock #1}\endcsname }% + \csname .=\xintFac{\XINT_expr_unlock #1}\endcsname }% \let\XINT_flexpr_op_!\XINT_expr_op_! \def\XINT_iiexpr_op_! #1{\expandafter\XINT_expr_getop - \csname .=\xintiFac{\XINT_expr_unlock #1}\endcsname }% -\def\XINT_tmpa #1#2#3#4{% - \def #1##1% + \csname .=\xintiFac{\XINT_expr_unlock #1}\endcsname }% +\catcode`[ 11 +\catcode`* 11 +\let\XINT_expr_precedence_[ \xint_c_vii +\def\XINT_expr_op_[ #1#2]{\expandafter\XINT_expr_getop + \csname .=\xintE{\XINT_expr_unlock #1}% + {\xint_zapspaces #2 \xint_bye\xint_bye}\endcsname}% +\def\XINT_iiexpr_op_[ #1#2]{\expandafter\XINT_expr_getop + \csname .=\xintiiE{\XINT_expr_unlock #1}% + {\xint_zapspaces #2 \xint_bye\xint_bye}\endcsname}% +\def\XINT_flexpr_op_[ #1#2]{\expandafter\XINT_expr_getop + \csname .=\XINTinFloatE{\XINT_expr_unlock #1}% + {\xint_zapspaces #2 \xint_bye\xint_bye}\endcsname}% +\catcode`[ 12 +\catcode`* 12 +\def\XINT_expr_op__ #1% op__ with two _'s + {% + \ifcsname XINT_expr_var_#1\endcsname + \expandafter\xint_firstoftwo + \else + \expandafter\xint_secondoftwo + \fi + {\expandafter\expandafter\expandafter\expandafter + \expandafter\expandafter\expandafter + \XINT_expr_getop\csname XINT_expr_var_#1\endcsname}% + {\XINT_expr_unknown_variable {#1}% + \expandafter\XINT_expr_getop\csname .=0\endcsname}% + }% +\def\XINT_expr_unknown_variable #1{\xintError:removed \xint_gobble_i {#1}}% +\let\XINT_flexpr_op__ \XINT_expr_op__ +\let\XINT_iiexpr_op__ \XINT_expr_op__ +\catcode`: 12 +\def\xintdefvar #1:=#2;{\expandafter\odef + \csname XINT_expr_var_\xint_zapspaces #1 \xint_bye\xint_bye\endcsname + {\expandafter\empty\romannumeral0\xintbareeval #2\relax }}% +\def\xintdefiivar #1:=#2;{\expandafter\odef + \csname XINT_expr_var_\xint_zapspaces #1 \xint_bye\xint_bye\endcsname + {\expandafter\empty\romannumeral0\xintbareiieval #2\relax }% +}% +\def\xintdeffloatvar #1:=#2;{\expandafter\odef + \csname XINT_expr_var_\xint_zapspaces #1 \xint_bye\xint_bye\endcsname + {\expandafter\empty\romannumeral0\xintbarefloateval #2\relax }% +}% +\catcode`: 11 +\def\XINT_tmpa #1% +{% + \expandafter\def\csname XINT_expr_var_#1\endcsname ##1\relax !#1##2% + {\romannumeral0\XINT_expr_lockscan ##2!##1\relax !#1{##2}}% +}% +\xintApplyUnbraced \XINT_tmpa {abcdefghijklmnopqrstuvwxyz}% +\xintApplyUnbraced \XINT_tmpa {ABCDEFGHIJKLMNOPQRSTUVWXYZ}% +\expandafter\def\expandafter\XINT_expr_var_nil\expandafter + {\expandafter\empty\csname .= \endcsname}% +\catcode`. 11 \catcode`= 11 +\def\XINT_expr_var_omit #1\relax !{1^C!{}{}{}\.=!\relax !}% 24 juin +\def\XINT_expr_var_abort #1\relax !{1^C!{}{}{}\.=^\relax !}% 25 juin +\catcode`. 12 \catcode`= 12 +\catcode`? 3 +\def\XINT_expr_var_@ #1~#2{ #2#1~#2}% +\expandafter\let\csname XINT_expr_var_@1\endcsname \XINT_expr_var_@ +\expandafter\def\csname XINT_expr_var_@2\endcsname #1~#2#3{ #3#1~#2#3}% +\expandafter\def\csname XINT_expr_var_@3\endcsname #1~#2#3#4{ #4#1~#2#3#4}% +\expandafter\def\csname XINT_expr_var_@4\endcsname #1~#2#3#4#5{ #5#1~#2#3#4#5}% +\def\XINT_expr_func_@@ #1#2#3#4~#5?% +{% + \expandafter#1\expandafter#2\romannumeral0\xintntheltnoexpand + {\xintNum{\XINT_expr_unlock#3}}{#5}#4~#5?% +}% +\def\XINT_expr_func_@@@ #1#2#3#4~#5~#6?% +{% + \expandafter#1\expandafter#2\romannumeral0\xintntheltnoexpand + {\xintNum{\XINT_expr_unlock#3}}{#6}#4~#5~#6?% +}% +\def\XINT_expr_func_@@@@ #1#2#3#4~#5~#6~#7?% +{% + \expandafter#1\expandafter#2\romannumeral0\xintntheltnoexpand + {\xintNum{\XINT_expr_unlock#3}}{#7}#4~#5~#6~#7?% +}% +\let\XINT_flexpr_func_@@\XINT_expr_func_@@ +\let\XINT_flexpr_func_@@@\XINT_expr_func_@@@ +\let\XINT_flexpr_func_@@@@\XINT_expr_func_@@@@ +\def\XINT_iiexpr_func_@@ #1#2#3#4~#5?% +{% + \expandafter#1\expandafter#2\romannumeral0\xintntheltnoexpand + {\XINT_expr_unlock#3}{#5}#4~#5?% +}% +\def\XINT_iiexpr_func_@@@ #1#2#3#4~#5~#6?% +{% + \expandafter#1\expandafter#2\romannumeral0\xintntheltnoexpand + {\XINT_expr_unlock#3}{#6}#4~#5~#6?% +}% +\def\XINT_iiexpr_func_@@@@ #1#2#3#4~#5~#6~#7?% +{% + \expandafter#1\expandafter#2\romannumeral0\xintntheltnoexpand + {\XINT_expr_unlock#3}{#7}#4~#5~#6~#7?% +}% +\catcode`? 11 +\def\XINT_tmpa #1#2#3{% + \def #1##1% \XINT_expr_op_`, #2=\XINT_expr_oparen {% \ifcsname XINT_expr_onlitteral_##1\endcsname - \expandafter\XINT_expr_funcoflitteral - \else - \expandafter #2% - \fi {##1}% - }% - \def #2##1% - {% - \ifcsname XINT_#4_func_##1\endcsname - \xint_afterfi - {\expandafter\expandafter\csname XINT_#4_func_##1\endcsname}% - \else \csname xintError:unknown `##1\string'\endcsname - \xint_afterfi{\expandafter\XINT_expr_func_unknown}% - \fi - \romannumeral-`0#3% + \xint_dothis{\csname XINT_expr_onlitteral_##1\endcsname}\fi + \ifcsname XINT_#3_func_##1\endcsname + \xint_dothis{\expandafter\expandafter + \csname XINT_#3_func_##1\endcsname\romannumeral-`0#2}\fi + \xint_orthat{\XINT_expr_unknown_function {##1}% + \expandafter\XINT_expr_func_unknown\romannumeral-`0#2}% }% }% +\def\XINT_expr_unknown_function #1{\xintError:removed \xint_gobble_i {#1}}% \xintFor #1 in {expr,flexpr,iiexpr} \do {% \expandafter\XINT_tmpa - \csname XINT_#1_op_@\expandafter\endcsname - \csname XINT_#1_op_@@\expandafter\endcsname - \csname XINT_#1_oparen\endcsname {#1}% -}% -\def\XINT_expr_funcoflitteral #1% -{% - \expandafter\expandafter\csname XINT_expr_onlitteral_#1\endcsname - \romannumeral-`0\XINT_expr_scanfunc -}% -\def\XINT_expr_onlitteral_bool #1#2#3{\expandafter\XINT_expr_getop - \csname .=\xintBool{#3}\endcsname }% -\def\XINT_expr_onlitteral_togl #1#2#3{\expandafter\XINT_expr_getop - \csname .=\xintToggle{#3}\endcsname }% -\def\XINT_expr_func_unknown #1#2#3% 1.09i removes [0], because \xintiiexpr - {\expandafter #1\expandafter #2\csname .=0\endcsname }% -\def\XINT_expr_func_reduce #1#2#3% -{% - \expandafter #1\expandafter #2\csname - .=\xintIrr {\XINT_expr_unlock #3}\endcsname -}% -\let\XINT_flexpr_func_reduce\XINT_expr_func_reduce -\def\XINT_expr_func_frac #1#2#3% -{% - \expandafter #1\expandafter #2\csname - .=\xintTFrac {\XINT_expr_unlock #3}\endcsname -}% -\def\XINT_flexpr_func_frac #1#2#3% -{% - \expandafter #1\expandafter #2\csname - .=\XINTinFloatFrac [\XINTdigits]{\XINT_expr_unlock #3}\endcsname -}% -\def\XINT_expr_func_sqr #1#2#3% + \csname XINT_#1_op_`\expandafter\endcsname + \csname XINT_#1_oparen\endcsname + {#1}% +}% +\expandafter\def\csname XINT_expr_onlitteral_`\endcsname #1#2#3({\xint_c_xviii `{#2}}% +\def\XINT_expr_onlitteral_bool #1)% + {\expandafter\XINT_expr_getop\csname .=\xintBool{#1}\endcsname }% +\def\XINT_expr_onlitteral_togl #1)% + {\expandafter\XINT_expr_getop\csname .=\xintToggle{#1}\endcsname }% +\def\XINT_expr_onlitteral_protect #1)% + {\expandafter\XINT_expr_getop\csname .=\detokenize{#1}\endcsname }% +\def\XINT_expr_func_unknown #1#2#3{\expandafter #1\expandafter #2\csname .=0\endcsname }% +\def\XINT_expr_func_break #1#2#3% +{\expandafter #1\expandafter #2\csname.=?\romannumeral-`0\XINT_expr_unlock #3\endcsname }% +\let\XINT_flexpr_func_break \XINT_expr_func_break +\let\XINT_iiexpr_func_break \XINT_expr_func_break +\def\XINT_expr_onlitteral_seq + {\expandafter\XINT_expr_onlitteral_seq_f\romannumeral-`0\XINT_expr_onlitteral_seq_a {}}% +\def\XINT_expr_onlitteral_seq_f #1#2{\xint_c_xviii `{seqx}#2)\relax #1}% +\def\XINT_expr_onlitteral_seq_a #1#2,% +{% checks balancing of parentheses + \ifcase\XINT_isbalanced_a \relax #1#2(\xint_bye)\xint_bye + \expandafter\XINT_expr_onlitteral_seq_c + \or\expandafter\XINT_expr_onlitteral_seq_b + \else\expandafter\xintError:we_are_doomed + \fi {#1#2},% +}% +\def\XINT_expr_onlitteral_seq_b #1,{\XINT_expr_onlitteral_seq_a {#1,}}% +\def\XINT_expr_onlitteral_seq_c #1,#2#3% #3 pour absorber le = +{% + \XINT_expr_onlitteral_seq_d {#2{#1}}{}% +}% +\def\XINT_expr_onlitteral_seq_d #1#2#3)% +{% + \ifcase\XINT_isbalanced_a \relax #2#3(\xint_bye)\xint_bye + \or\expandafter\XINT_expr_onlitteral_seq_e + \else\expandafter\xintError:we_are_doomed + \fi + {#1}{#2#3}% +}% +\def\XINT_expr_onlitteral_seq_e #1#2{\XINT_expr_onlitteral_seq_d {#1}{#2)}}% +\def\XINT_isbalanced_a #1({\XINT_isbalanced_b #1)\xint_bye }% +\def\XINT_isbalanced_b #1)#2% + {\xint_bye #2\XINT_isbalanced_c\xint_bye\XINT_isbalanced_error }% +\def\XINT_isbalanced_error #1)\xint_bye {\m@ne}% +\def\XINT_isbalanced_c\xint_bye\XINT_isbalanced_error #1% + {\xint_bye #1\XINT_isbalanced_yes\xint_bye\XINT_isbalanced_d #1}% +\def\XINT_isbalanced_yes\xint_bye\XINT_isbalanced_d\xint_bye )\xint_bye {\xint_c_ }% +\def\XINT_isbalanced_d #1)#2% + {\xint_bye #2\XINT_isbalanced_no\xint_bye\XINT_isbalanced_a #1#2}% +\def\XINT_isbalanced_no\xint_bye #1\xint_bye\xint_bye {\xint_c_i }% +\def\XINT_expr_func_seqx #1#2{\XINT_allexpr_seqx \xintbareeval }% +\def\XINT_flexpr_func_seqx #1#2{\XINT_allexpr_seqx \xintbarefloateval}% +\def\XINT_iiexpr_func_seqx #1#2{\XINT_allexpr_seqx \xintbareiieval }% +\def\XINT_allexpr_seqx #1#2#3#4% #2 is the index list, fully evaluated and encapsulated +{% #3 is the Latin letter serving as dummy variable, #4 is the expression to evaluate + \expandafter \XINT_expr_getop + \csname .=\expandafter\XINT_expr_seq:_aa + \romannumeral-`0\XINT_expr_unlock #2!{#1#4\relax !#3},^,\endcsname +}% +\def\XINT_expr_seq:_aa #1{\if +#1\expandafter\XINT_expr_seq:_A\else + \expandafter\XINT_expr_seq:_a\fi #1}% +\def\XINT_expr_seq:_a #1!#2{\expandafter\XINT_expr_seq_empty? + \romannumeral0\XINT_expr_seq:_b {#2}#1}% +\def\XINT_expr_seq:_b #1#2,{\XINT_expr_seq:_c #2,{#1}}% +\def\XINT_expr_seq:_c #1{\if ,#1\xint_dothis\XINT_expr_seq:_noop\fi + \if ^#1\xint_dothis\XINT_expr_seq:_end\fi + \xint_orthat\XINT_expr_seq:_d #1}% +\def\XINT_expr_seq:_d #1,#2{\expandafter\XINT_expr_seq:_e + \romannumeral-`0\expandafter\XINT_expr_unlock\romannumeral0#2{#1}{#2}}% +\def\XINT_expr_seq:_e #1{\if #1^\xint_dothis\XINT_expr_seq:_abort\fi + \if #1?\xint_dothis\XINT_expr_seq:_break\fi + \if #1!\xint_dothis\XINT_expr_seq:_omit\fi + \xint_orthat{\XINT_expr_seq:_goon #1}}% +\def\XINT_expr_seq:_goon #1!#2#3#4{,#1\XINT_expr_seq:_b {#4}}% +\def\XINT_expr_seq:_omit #1!#2#3#4{\XINT_expr_seq:_b {#4}}% +\def\XINT_expr_seq:_abort #1!#2#3#4#5^,{}% +\def\XINT_expr_seq:_break #1!#2#3#4#5^,{,#1}% +\def\XINT_expr_seq:_noop ,#1{\XINT_expr_seq:_b {#1}}% +\def\XINT_expr_seq:_end ^,#1{}% if all is omit, _empty? constructs "nil" +\def\XINT_expr_seq_empty? #1{% +\def\XINT_expr_seq_empty? ##1{\if ,##1\expandafter\xint_gobble_i\fi #1\endcsname }}% +\XINT_expr_seq_empty? { }% +\def\XINT_expr_seq:_A +#1!#2,^,% + {\expandafter\XINT_expr_seq_empty?\romannumeral0\XINT_expr_seq:_D {#1}{#2}}% +\def\XINT_expr_seq:_D #1#2{\expandafter\XINT_expr_seq:_E + \romannumeral-`0\expandafter\XINT_expr_unlock\romannumeral0#2{#1}{#2}}% +\def\XINT_expr_seq:_E #1{\if #1^\xint_dothis\XINT_expr_seq:_Abort\fi + \if #1?\xint_dothis\XINT_expr_seq:_Break\fi + \if #1!\xint_dothis\XINT_expr_seq:_Omit\fi + \xint_orthat{\XINT_expr_seq:_Goon #1}}% +\def\XINT_expr_seq:_Goon #1!#2#3#4% + {,#1\expandafter\XINT_expr_seq:_D\expandafter{\the\numexpr #3+\xint_c_i}{#4}}% +\def\XINT_expr_seq:_Omit #1!#2#3#4% + {\expandafter\XINT_expr_seq:_D\expandafter{\the\numexpr #3+\xint_c_i}{#4}}% +\def\XINT_expr_seq:_Abort #1!#2#3#4{}% +\def\XINT_expr_seq:_Break #1!#2#3#4{,#1}% +\def\XINT_expr_onlitteral_add + {\expandafter\XINT_expr_onlitteral_add_f\romannumeral-`0\XINT_expr_onlitteral_seq_a {}}% +\def\XINT_expr_onlitteral_add_f #1#2{\xint_c_xviii `{opx}#2)\relax #1+}% +\def\XINT_expr_onlitteral_mul + {\expandafter\XINT_expr_onlitteral_mul_f\romannumeral-`0\XINT_expr_onlitteral_seq_a {}}% +\def\XINT_expr_onlitteral_mul_f #1#2{\xint_c_xviii `{opx}#2)\relax #1*}% +\expandafter\edef\csname XINT_expr_op:_+\endcsname + {\noexpand\xint_gobble_v {}{}{}\expandafter\noexpand\csname .=0\endcsname}% +\expandafter\edef\csname XINT_expr_op:_*\endcsname + {\noexpand\xint_gobble_v {}{}{}\expandafter\noexpand\csname .=1\endcsname}% +\def\XINT_expr_func_opx #1#2{\XINT_allexpr_opx \xintexpr }% +\def\XINT_flexpr_func_opx #1#2{\XINT_allexpr_opx \xintfloatexpr }% +\def\XINT_iiexpr_func_opx #1#2{\XINT_allexpr_opx \xintiiexpr }% +\def\XINT_allexpr_opx #1#2#3#4#5% +{% au d^^e9part on avait op(#4,#3=#2 (^^e9valu^^e9 ici)) #3=la variable, #4=expression, #5=+ ou*. + \expandafter\XINT_expr_getop\romannumeral0\expandafter\XINT_expr_op:_a + \csname XINT_expr_op:_#5\expandafter\endcsname + \romannumeral-`0\XINT_expr_unlock #2!#5#1#3{#4}% +}% +\def\XINT_expr_op:_a #1#2!#3#4#5#6{\XINT_expr_op:_b {#1#4#3{#6\relax\relax !#5}}#2,^,}% +\def\XINT_expr_op:_b #1#2,{\XINT_expr_op:_c #2,#1}% +\def\XINT_expr_op:_c #1{\if ,#1\xint_dothis\XINT_expr_op:_noop\fi + \if ^#1\xint_dothis\XINT_expr_op:_end\fi + \xint_orthat\XINT_expr_op:_d #1}% +\def\XINT_expr_op:_noop #1,#2#3#4#5{\XINT_expr_op:_b {{#2}#3#4{#5}}}% +\def\XINT_expr_op:_d #1,#2#3#4#5% + {\expandafter\expandafter\expandafter\XINT_expr_op:_e #3#2#4#3#5{#1}{#3#4{#5}}}% +\def\XINT_expr_op:_e !#1!#2#3#4{\XINT_expr_op:_b {{!#1}#4}}% +\def\XINT_expr_op:_end ^,#1#2#3#4{\expandafter\expandafter\expandafter\space + \expandafter\xint_gobble_iv #1}% +\def\XINT_expr_onlitteral_subs + {\expandafter\XINT_expr_onlitteral_subs_f\romannumeral-`0\XINT_expr_onlitteral_seq_a {}}% +\def\XINT_expr_onlitteral_subs_f #1#2{\xint_c_xviii `{subx}#2)\relax #1}% +\def\XINT_expr_func_subx #1#2{\XINT_allexpr_subx \xintbareeval }% +\def\XINT_flexpr_func_subx #1#2{\XINT_allexpr_subx \xintbarefloateval}% +\def\XINT_iiexpr_func_subx #1#2{\XINT_allexpr_subx \xintbareiieval }% +\def\XINT_allexpr_subx #1#2#3#4% #2 is the value to assign to the dummy variable +{% #3 is the dummy variable, #4 is the expression to evaluate + \expandafter \XINT_expr_getop + \csname .=\expandafter\XINT_expr_subx:_a + \romannumeral-`0\XINT_expr_unlock #2!{#1#4\relax !#3}\endcsname +}% +\def\XINT_expr_subx:_a #1!#2% 10/25 that was a quick addition! + {\expandafter\XINT_expr_subx:_end \romannumeral0#2{#1}}% +\def\XINT_expr_subx:_end #1!#2#3{\XINT_expr_unlock #1}% +\def\XINT_expr_func_rseq {\XINT_allexpr_rseq \xintbareeval }% +\def\XINT_flexpr_func_rseq {\XINT_allexpr_rseq \xintbarefloateval }% +\def\XINT_iiexpr_func_rseq {\XINT_allexpr_rseq \xintbareiieval }% +\def\XINT_allexpr_rseq #1#2% +{% + \expandafter\XINT_expr_rseqx\expandafter #1\expandafter + #2\romannumeral-`0\XINT_expr_onlitteral_seq_a {}% +}% +\def\XINT_expr_rseqx #1#2#3#4% +{% + \expandafter\XINT_expr_rseqy\romannumeral0#1(#4)\relax + #2#3#1% +}% +\def\XINT_expr_rseqy #1#2#3#4#5% #1=valeurs pour variable (locked), + % #2=toutes les valeurs initiales (csv,locked), + % #3=variable, #4=expr, + % #5=\xintbareeval ou \xintbarefloateval ou \xintbareiieval +{% + \expandafter \XINT_expr_getop + \csname .=\XINT_expr_unlock #2% + \expandafter\XINT_expr_rseq:_aa + \romannumeral-`0\XINT_expr_unlock #1!{#5#4\relax !#3}#2,^,\endcsname +}% +\def\XINT_expr_rseq:_aa #1{\if +#1\expandafter\XINT_expr_rseq:_A\else + \expandafter\XINT_expr_rseq:_a\fi #1}% +\def\XINT_expr_rseq:_a #1!#2#3{\XINT_expr_rseq:_b #3{#2}#1}% +\def\XINT_expr_rseq:_b #1#2#3,{\XINT_expr_rseq:_c #3,~#1{#2}}% +\def\XINT_expr_rseq:_c #1{\if ,#1\xint_dothis\XINT_expr_rseq:_noop\fi + \if ^#1\xint_dothis\XINT_expr_rseq:_end\fi + \xint_orthat\XINT_expr_rseq:_d #1}% +\def\XINT_expr_rseq:_d #1,~#2#3{\expandafter\XINT_expr_rseq:_e + \romannumeral-`0\expandafter\XINT_expr_unlock\romannumeral0#3{#1}~#2{#3}}% +\def\XINT_expr_rseq:_e #1{% + \if ^#1\xint_dothis\XINT_expr_rseq:_abort\fi + \if ?#1\xint_dothis\XINT_expr_rseq:_break\fi + \if !#1\xint_dothis\XINT_expr_rseq:_omit\fi + \xint_orthat{\XINT_expr_rseq:_goon #1}}% +\def\XINT_expr_rseq:_goon #1!#2#3~#4#5{,#1\expandafter\XINT_expr_rseq:_b + \romannumeral0\XINT_expr_lockit {#1}{#5}}% +\def\XINT_expr_rseq:_omit #1!#2#3~{\XINT_expr_rseq:_b }% +\def\XINT_expr_rseq:_abort #1!#2#3~#4#5#6^,{}% +\def\XINT_expr_rseq:_break #1!#2#3~#4#5#6^,{,#1}% +\def\XINT_expr_rseq:_noop ,~#1#2{\XINT_expr_rseq:_b #1{#2}}% +\def\XINT_expr_rseq:_end ^,~#1#2{}% no nil for rseq +\def\XINT_expr_rseq:_A +#1!#2#3,^,{\XINT_expr_rseq:_D {#1}#3{#2}}% +\def\XINT_expr_rseq:_D #1#2#3{\expandafter\XINT_expr_rseq:_E + \romannumeral-`0\expandafter\XINT_expr_unlock\romannumeral0#3{#1}~#2{#3}}% +\def\XINT_expr_rseq:_E #1{\if #1^\xint_dothis\XINT_expr_rseq:_Abort\fi + \if #1?\xint_dothis\XINT_expr_rseq:_Break\fi + \if #1!\xint_dothis\XINT_expr_rseq:_Omit\fi + \xint_orthat{\XINT_expr_rseq:_Goon #1}}% +\def\XINT_expr_rseq:_Goon #1!#2#3~#4#5% + {,#1\expandafter\XINT_expr_rseq:_D\expandafter{\the\numexpr #3+\xint_c_i\expandafter}% + \romannumeral0\XINT_expr_lockit{#1}{#5}}% +\def\XINT_expr_rseq:_Omit #1!#2#3~%#4#5% + {\expandafter\XINT_expr_rseq:_D\expandafter{\the\numexpr #3+\xint_c_i}}% +\def\XINT_expr_rseq:_Abort #1!#2#3~#4#5{}% +\def\XINT_expr_rseq:_Break #1!#2#3~#4#5{,#1}% +\def\XINT_expr_func_rrseq {\XINT_allexpr_rrseq \xintbareeval }% +\def\XINT_flexpr_func_rrseq {\XINT_allexpr_rrseq \xintbarefloateval }% +\def\XINT_iiexpr_func_rrseq {\XINT_allexpr_rrseq \xintbareiieval }% +\def\XINT_allexpr_rrseq #1#2% +{% + \expandafter\XINT_expr_rrseqx\expandafter #1\expandafter + #2\romannumeral-`0\XINT_expr_onlitteral_seq_a {}% +}% +\def\XINT_expr_rrseqx #1#2#3#4% +{% + \expandafter\XINT_expr_rrseqy\romannumeral0#1(#4)\expandafter\relax + \expandafter{\romannumeral0\xintapply \XINT_expr_lockit + {\xintRevWithBraces{\xintCSVtoListNonStripped{\XINT_expr_unlock #2}}}}% + #2#3#1% +}% +\def\XINT_expr_rrseqy #1#2#3#4#5#6% #1=valeurs pour variable (locked), + % #2=initial values (reversed, one (braced) token each) + % #3=toutes les valeurs initiales (csv,locked), + % #4=variable, #5=expr, + % #6=\xintbareeval ou \xintbarefloateval ou \xintbareiieval +{% + \expandafter \XINT_expr_getop + \csname .=\XINT_expr_unlock #3% + \expandafter\XINT_expr_rrseq:_aa + \romannumeral-`0\XINT_expr_unlock #1!{#6#5\relax !#4}{#2},^,\endcsname +}% +\def\XINT_expr_rrseq:_aa #1{\if +#1\expandafter\XINT_expr_rrseq:_A\else + \expandafter\XINT_expr_rrseq:_a\fi #1}% +\catcode`? 3 +\def\XINT_expr_rrseq:_a #1!#2#3{\XINT_expr_rrseq:_b {#3}{#2}#1}% +\def\XINT_expr_rrseq:_b #1#2#3,{\XINT_expr_rrseq:_c #3,~#1?{#2}}% +\def\XINT_expr_rrseq:_c #1{\if ,#1\xint_dothis\XINT_expr_rrseq:_noop\fi + \if ^#1\xint_dothis\XINT_expr_rrseq:_end\fi + \xint_orthat\XINT_expr_rrseq:_d #1}% +\def\XINT_expr_rrseq:_d #1,~#2?#3{\expandafter\XINT_expr_rrseq:_e + \romannumeral-`0\expandafter\XINT_expr_unlock\romannumeral0#3{#1}~#2?{#3}}% +\def\XINT_expr_rrseq:_goon #1!#2#3~#4?#5{,#1\expandafter\XINT_expr_rrseq:_b\expandafter + {\romannumeral0\xinttrim{-1}{\XINT_expr_lockit{#1}#4}}{#5}}% +\def\XINT_expr_rrseq:_omit #1!#2#3~{\XINT_expr_rrseq:_b }% +\def\XINT_expr_rrseq:_abort #1!#2#3~#4?#5#6^,{}% +\def\XINT_expr_rrseq:_break #1!#2#3~#4?#5#6^,{,#1}% +\def\XINT_expr_rrseq:_noop ,~#1?#2{\XINT_expr_rrseq:_b {#1}{#2}}% +\def\XINT_expr_rrseq:_end ^,~#1?#2{}% No nil for rrseq. +\catcode`? 11 +\def\XINT_expr_rrseq:_e #1{% + \if ^#1\xint_dothis\XINT_expr_rrseq:_abort\fi + \if ?#1\xint_dothis\XINT_expr_rrseq:_break\fi + \if !#1\xint_dothis\XINT_expr_rrseq:_omit\fi + \xint_orthat{\XINT_expr_rrseq:_goon #1}% +}% +\catcode`? 3 +\def\XINT_expr_rrseq:_A +#1!#2#3,^,{\XINT_expr_rrseq:_D {#1}{#3}{#2}}% +\def\XINT_expr_rrseq:_D #1#2#3{\expandafter\XINT_expr_rrseq:_E + \romannumeral-`0\expandafter\XINT_expr_unlock\romannumeral0#3{#1}~#2?{#3}}% +\def\XINT_expr_rrseq:_Goon #1!#2#3~#4?#5% + {,#1\expandafter\XINT_expr_rrseq:_D\expandafter{\the\numexpr #3+\xint_c_i\expandafter}% + \expandafter{\romannumeral0\xinttrim{-1}{\XINT_expr_lockit{#1}#4}}{#5}}% +\def\XINT_expr_rrseq:_Omit #1!#2#3~%#4?#5% + {\expandafter\XINT_expr_rrseq:_D\expandafter{\the\numexpr #3+\xint_c_i}}% +\def\XINT_expr_rrseq:_Abort #1!#2#3~#4?#5{}% +\def\XINT_expr_rrseq:_Break #1!#2#3~#4?#5{,#1}% +\catcode`? 11 +\def\XINT_expr_rrseq:_E #1{\if #1^\xint_dothis\XINT_expr_rrseq:_Abort\fi + \if #1?\xint_dothis\XINT_expr_rrseq:_Break\fi + \if #1!\xint_dothis\XINT_expr_rrseq:_Omit\fi + \xint_orthat{\XINT_expr_rrseq:_Goon #1}}% +\def\XINT_expr_func_iter {\XINT_allexpr_iter \xintbareeval }% +\def\XINT_flexpr_func_iter {\XINT_allexpr_iter \xintbarefloateval }% +\def\XINT_iiexpr_func_iter {\XINT_allexpr_iter \xintbareiieval }% +\def\XINT_allexpr_iter #1#2% +{% + \expandafter\XINT_expr_iterx\expandafter #1\expandafter + #2\romannumeral-`0\XINT_expr_onlitteral_seq_a {}% +}% +\def\XINT_expr_iterx #1#2#3#4% +{% + \expandafter\XINT_expr_itery\romannumeral0#1(#4)\expandafter\relax + \expandafter{\romannumeral0\xintapply \XINT_expr_lockit + {\xintRevWithBraces{\xintCSVtoListNonStripped{\XINT_expr_unlock #2}}}}% + #2#3#1% +}% +\def\XINT_expr_itery #1#2#3#4#5#6% #1=valeurs pour variable (locked), + % #2=initial values (reversed, one (braced) token each) + % #3=toutes les valeurs initiales (csv,locked), + % #4=variable, #5=expr, + % #6=\xintbareeval ou \xintbarefloateval ou \xintbareiieval +{% + \expandafter \XINT_expr_getop + \csname .=% + \expandafter\XINT_expr_iter:_aa + \romannumeral-`0\XINT_expr_unlock #1!{#6#5\relax !#4}{#2},^,\endcsname +}% +\def\XINT_expr_iter:_aa #1{\if +#1\expandafter\XINT_expr_iter:_A\else + \expandafter\XINT_expr_iter:_a\fi #1}% +\catcode`? 3 +\def\XINT_expr_iter:_a #1!#2#3{\XINT_expr_iter:_b {#3}{#2}#1}% +\def\XINT_expr_iter:_b #1#2#3,{\XINT_expr_iter:_c #3,~#1?{#2}}% +\def\XINT_expr_iter:_c #1{\if ,#1\xint_dothis\XINT_expr_iter:_noop\fi + \if ^#1\xint_dothis\XINT_expr_iter:_end\fi + \xint_orthat\XINT_expr_iter:_d #1}% +\def\XINT_expr_iter:_d #1,~#2?#3{\expandafter\XINT_expr_iter:_e + \romannumeral-`0\expandafter\XINT_expr_unlock\romannumeral0#3{#1}~#2?{#3}}% +\def\XINT_expr_iter:_goon #1!#2#3~#4?#5{\expandafter\XINT_expr_iter:_b\expandafter + {\romannumeral0\xinttrim{-1}{\XINT_expr_lockit{#1}#4}}{#5}}% +\def\XINT_expr_iter:_omit #1!#2#3~{\XINT_expr_iter:_b }% +\def\XINT_expr_iter:_abort #1!#2#3~#4?#5#6^,% + {\expandafter\xint_gobble_i\romannumeral0\xintapplyunbraced + {,\XINT_expr:_unlock}{\xintReverseOrder{#4\space}}}% +\def\XINT_expr_iter:_break #1!#2#3~#4?#5#6^,% + {\expandafter\xint_gobble_iv\romannumeral0\xintapplyunbraced + {,\XINT_expr:_unlock}{\xintReverseOrder{#4\space}},#1}% +\def\XINT_expr_iter:_noop ,~#1?#2{\XINT_expr_iter:_b {#1}{#2}}% +\def\XINT_expr_iter:_end ^,~#1?#2% + {\expandafter\xint_gobble_i\romannumeral0\xintapplyunbraced + {,\XINT_expr:_unlock}{\xintReverseOrder{#1\space}}}% +\catcode`? 11 +\def\XINT_expr_iter:_e #1{% + \if ^#1\xint_dothis\XINT_expr_iter:_abort\fi + \if ?#1\xint_dothis\XINT_expr_iter:_break\fi + \if !#1\xint_dothis\XINT_expr_iter:_omit\fi + \xint_orthat{\XINT_expr_iter:_goon #1}% +}% +\def\XINT_expr:_unlock #1{\XINT_expr_unlock #1}% +\catcode`? 3 +\def\XINT_expr_iter:_A +#1!#2#3,^,{\XINT_expr_iter:_D {#1}{#3}{#2}}% +\def\XINT_expr_iter:_D #1#2#3{\expandafter\XINT_expr_iter:_E + \romannumeral-`0\expandafter\XINT_expr_unlock\romannumeral0#3{#1}~#2?{#3}}% +\def\XINT_expr_iter:_Goon #1!#2#3~#4?#5% + {\expandafter\XINT_expr_iter:_D\expandafter{\the\numexpr #3+\xint_c_i\expandafter}% + \expandafter{\romannumeral0\xinttrim{-1}{\XINT_expr_lockit{#1}#4}}{#5}}% +\def\XINT_expr_iter:_Omit #1!#2#3~%#4?#5% + {\expandafter\XINT_expr_iter:_D\expandafter{\the\numexpr #3+\xint_c_i}}% +\def\XINT_expr_iter:_Abort #1!#2#3~#4?#5% + {\expandafter\xint_gobble_i\romannumeral0\xintapplyunbraced + {,\XINT_expr:_unlock}{\xintReverseOrder{#4\space}}}% +\def\XINT_expr_iter:_Break #1!#2#3~#4?#5% + {\expandafter\xint_gobble_iv\romannumeral0\xintapplyunbraced + {,\XINT_expr:_unlock}{\xintReverseOrder{#4\space}},#1}% +\catcode`? 11 +\def\XINT_expr_iter:_E #1{\if #1^\xint_dothis\XINT_expr_iter:_Abort\fi + \if #1?\xint_dothis\XINT_expr_iter:_Break\fi + \if #1!\xint_dothis\XINT_expr_iter:_Omit\fi + \xint_orthat{\XINT_expr_iter:_Goon #1}}% +\def\xintANDof:csv #1{\expandafter\XINT_andof:_a\romannumeral-`0#1,,^}% +\def\XINT_andof:_a #1{\if ,#1\expandafter\XINT_andof:_e + \else\expandafter\XINT_andof:_c\fi #1}% +\def\XINT_andof:_c #1,{\xintiiifNotZero {#1}{\XINT_andof:_a}{\XINT_andof:_no}}% +\def\XINT_andof:_no #1^{0}% +\def\XINT_andof:_e #1^{1}% works with empty list +\def\xintORof:csv #1{\expandafter\XINT_orof:_a\romannumeral-`0#1,,^}% +\def\XINT_orof:_a #1{\if ,#1\expandafter\XINT_orof:_e + \else\expandafter\XINT_orof:_c\fi #1}% +\def\XINT_orof:_c #1,{\xintiiifNotZero{#1}{\XINT_orof:_yes}{\XINT_orof:_a}}% +\def\XINT_orof:_yes #1^{1}% +\def\XINT_orof:_e #1^{0}% works with empty list +\def\xintXORof:csv #1{\expandafter\XINT_xorof:_a\expandafter 0\romannumeral-`0#1,,^}% +\def\XINT_xorof:_a #1#2,{\XINT_xorof:_b #2,#1}% +\def\XINT_xorof:_b #1{\if ,#1\expandafter\XINT_xorof:_e + \else\expandafter\XINT_xorof:_c\fi #1}% +\def\XINT_xorof:_c #1,#2% + {\xintiiifNotZero {#1}{\if #20\xint_afterfi{\XINT_xorof:_a 1}% + \else\xint_afterfi{\XINT_xorof:_a 0}\fi}% + {\XINT_xorof:_a #2}% + }% +\def\XINT_xorof:_e ,#1#2^{#1}% allows empty list (then returns 0) +\def\XINT_oncsv:_empty #1,^,#2{#2}% +\def\XINT_oncsv:_end ^,#1#2#3#4{#1}% +\def\XINT_oncsv:_a #1#2#3% + {\if ,#3\expandafter\XINT_oncsv:_empty\else\expandafter\XINT_oncsv:_b\fi #1#2#3}% +\def\XINT_oncsv:_b #1#2#3,% + {\expandafter\XINT_oncsv:_c \expandafter{\romannumeral-`0#2{#3}}#1#2}% +\def\XINT_oncsv:_c #1#2#3#4,{\expandafter\XINT_oncsv:_d \romannumeral-`0#4,{#1}#2#3}% +\def\XINT_oncsv:_d #1% + {\if ^#1\expandafter\XINT_oncsv:_end\else\expandafter\XINT_oncsv:_e\fi #1}% +\def\XINT_oncsv:_e #1,#2#3#4% + {\expandafter\XINT_oncsv:_c\expandafter {\romannumeral-`0#3{#4{#1}}{#2}}#3#4}% +\def\xintMaxof:csv #1{\expandafter\XINT_oncsv:_a\expandafter\xintmax + \expandafter\xint_firstofone\romannumeral-`0#1,^,{0/1[0]}}% +\def\xintiiMaxof:csv #1{\expandafter\XINT_oncsv:_a\expandafter\xintiimax + \expandafter\xint_firstofone\romannumeral-`0#1,^,0}% +\def\xintMinof:csv #1{\expandafter\XINT_oncsv:_a\expandafter\xintmin + \expandafter\xint_firstofone\romannumeral-`0#1,^,{0/1[0]}}% +\def\xintiiMinof:csv #1{\expandafter\XINT_oncsv:_a\expandafter\xintiimin + \expandafter\xint_firstofone\romannumeral-`0#1,^,0}% +\def\xintSum:csv #1{\expandafter\XINT_oncsv:_a\expandafter\xintadd + \expandafter\xint_firstofone\romannumeral-`0#1,^,{0/1[0]}}% +\def\xintiiSum:csv #1{\expandafter\XINT_oncsv:_a\expandafter\xintiiadd + \expandafter\xint_firstofone\romannumeral-`0#1,^,0}% +\def\xintPrd:csv #1{\expandafter\XINT_oncsv:_a\expandafter\xintmul + \expandafter\xint_firstofone\romannumeral-`0#1,^,{1/1[0]}}% +\def\xintiiPrd:csv #1{\expandafter\XINT_oncsv:_a\expandafter\xintiimul + \expandafter\xint_firstofone\romannumeral-`0#1,^,1}% +\def\xintGCDof:csv #1{\expandafter\XINT_oncsv:_a\expandafter\xintgcd + \expandafter\xint_firstofone\romannumeral-`0#1,^,1}% +\def\xintLCMof:csv #1{\expandafter\XINT_oncsv:_a\expandafter\xintlcm + \expandafter\xint_firstofone\romannumeral-`0#1,^,0}% +\def\XINTinFloatdigits {\XINTinFloat [\XINTdigits]}% +\def\XINTinFloatSqrtdigits {\XINTinFloatSqrt [\XINTdigits]}% +\def\XINTinFloatMaxof:csv #1{\expandafter\XINT_oncsv:_a\expandafter\xintmax + \expandafter\XINTinFloatdigits\romannumeral-`0#1,^,{0[0]}}% +\def\XINTinFloatMinof:csv #1{\expandafter\XINT_oncsv:_a\expandafter\xintmin + \expandafter\XINTinFloatdigits\romannumeral-`0#1,^,{0[0]}}% +\def\XINTinFloatSum:csv #1{\expandafter\XINT_oncsv:_a\expandafter\XINTinfloatadd + \expandafter\XINTinFloatdigits\romannumeral-`0#1,^,{0[0]}}% +\def\XINTinFloatPrd:csv #1{\expandafter\XINT_oncsv:_a\expandafter\XINTinfloatmul + \expandafter\XINTinFloatdigits\romannumeral-`0#1,^,{1[0]}}% +\def\XINT_expr_twoargs #1,#2,{{#1}{#2}}% +\def\XINT_expr_argandopt #1,#2,#3.#4#5% {% - \expandafter #1\expandafter #2\csname - .=\xintSqr {\XINT_expr_unlock #3}\endcsname + \if\relax#3\relax\expandafter\xint_firstoftwo\else + \expandafter\xint_secondoftwo\fi + {#4}{#5[\xintNum {#2}]}{#1}% }% -\def\XINT_flexpr_func_sqr #1#2#3% +\def\XINT_expr_oneortwo #1#2#3,#4,#5.% {% - \expandafter #1\expandafter #2\csname - .=\XINTinFloatMul [\XINTdigits]% - {\XINT_expr_unlock #3}{\XINT_expr_unlock #3}\endcsname + \if\relax#5\relax\expandafter\xint_firstoftwo\else + \expandafter\xint_secondoftwo\fi + {#1{0}}{#2{\xintNum {#4}}}{#3}% }% -\def\XINT_iiexpr_func_sqr #1#2#3% +\def\XINT_iiexpr_oneortwo #1#2,#3,#4.% {% - \expandafter #1\expandafter #2\csname - .=\xintiiSqr {\XINT_expr_unlock #3}\endcsname + \if\relax#4\relax\expandafter\xint_firstoftwo\else + \expandafter\xint_secondoftwo\fi + {#1{0}}{#1{#3}}{#2}% }% +\def\XINT_expr_func_num #1#2#3% + {\expandafter #1\expandafter #2\csname.=\xintNum {\XINT_expr_unlock #3}\endcsname }% +\let\XINT_flexpr_func_num\XINT_expr_func_num +\let\XINT_iiexpr_func_num\XINT_expr_func_num +\def\XINT_expr_func_reduce #1#2#3% + {\expandafter #1\expandafter #2\csname.=\xintIrr {\XINT_expr_unlock #3}[0]\endcsname }% +\let\XINT_flexpr_func_reduce\XINT_expr_func_reduce \def\XINT_expr_func_abs #1#2#3% -{% - \expandafter #1\expandafter #2\csname - .=\xintAbs {\XINT_expr_unlock #3}\endcsname -}% + {\expandafter #1\expandafter #2\csname.=\xintAbs {\XINT_expr_unlock #3}\endcsname }% \let\XINT_flexpr_func_abs\XINT_expr_func_abs \def\XINT_iiexpr_func_abs #1#2#3% -{% - \expandafter #1\expandafter #2\csname - .=\xintiiAbs {\XINT_expr_unlock #3}\endcsname -}% + {\expandafter #1\expandafter #2\csname.=\xintiiAbs {\XINT_expr_unlock #3}\endcsname }% \def\XINT_expr_func_sgn #1#2#3% -{% - \expandafter #1\expandafter #2\csname - .=\xintSgn {\XINT_expr_unlock #3}\endcsname -}% + {\expandafter #1\expandafter #2\csname.=\xintSgn {\XINT_expr_unlock #3}\endcsname }% \let\XINT_flexpr_func_sgn\XINT_expr_func_sgn \def\XINT_iiexpr_func_sgn #1#2#3% -{% - \expandafter #1\expandafter #2\csname - .=\xintiiSgn {\XINT_expr_unlock #3}\endcsname -}% + {\expandafter #1\expandafter #2\csname.=\xintiiSgn {\XINT_expr_unlock #3}\endcsname }% +\def\XINT_expr_func_frac #1#2#3% + {\expandafter #1\expandafter #2\csname.=\xintTFrac {\XINT_expr_unlock #3}\endcsname }% +\def\XINT_flexpr_func_frac #1#2#3{\expandafter #1\expandafter #2\csname + .=\XINTinFloatFrac {\XINT_expr_unlock #3}\endcsname }% \def\XINT_expr_func_floor #1#2#3% -{% - \expandafter #1\expandafter #2\csname - .=\xintFloor {\XINT_expr_unlock #3}\endcsname -}% + {\expandafter #1\expandafter #2\csname .=\xintFloor {\XINT_expr_unlock #3}\endcsname }% \let\XINT_flexpr_func_floor\XINT_expr_func_floor -\let\XINT_iiexpr_func_floor\XINT_expr_func_floor +\def\XINT_iiexpr_func_floor #1#2#3% +{% mais absurde si on ne peut pas avoir quotient comme input + \expandafter #1\expandafter #2\csname.=\xintiFloor {\XINT_expr_unlock #3}\endcsname }% \def\XINT_expr_func_ceil #1#2#3% -{% - \expandafter #1\expandafter #2\csname - .=\xintCeil {\XINT_expr_unlock #3}\endcsname -}% + {\expandafter #1\expandafter #2\csname .=\xintCeil {\XINT_expr_unlock #3}\endcsname }% \let\XINT_flexpr_func_ceil\XINT_expr_func_ceil -\let\XINT_iiexpr_func_ceil\XINT_expr_func_ceil -\def\XINT_expr_twoargs #1,#2,{{#1}{#2}}% -\def\XINT_expr_func_quo #1#2#3% -{% - \expandafter #1\expandafter #2\csname .=% - \expandafter\expandafter\expandafter\xintQuo - \expandafter\XINT_expr_twoargs - \romannumeral-`0\XINT_expr_unlock #3,\endcsname -}% -\let\XINT_flexpr_func_quo\XINT_expr_func_quo -\def\XINT_iiexpr_func_quo #1#2#3% -{% - \expandafter #1\expandafter #2\csname .=% - \expandafter\expandafter\expandafter\xintiiQuo - \expandafter\XINT_expr_twoargs - \romannumeral-`0\XINT_expr_unlock #3,\endcsname -}% -\def\XINT_expr_func_rem #1#2#3% +\def\XINT_iiexpr_func_ceil #1#2#3% +{% mais absurde si on ne peut pas avoir quotient comme input + \expandafter #1\expandafter #2\csname.=\xintiCeil {\XINT_expr_unlock #3}\endcsname }% +\def\XINT_expr_func_sqr #1#2#3% + {\expandafter #1\expandafter #2\csname.=\xintSqr {\XINT_expr_unlock #3}\endcsname }% +\def\XINT_flexpr_func_sqr #1#2#3% {% - \expandafter #1\expandafter #2\csname .=% - \expandafter\expandafter\expandafter\xintRem - \expandafter\XINT_expr_twoargs - \romannumeral-`0\XINT_expr_unlock #3,\endcsname + \expandafter #1\expandafter #2\csname + .=\XINTinFloatMul % [\XINTdigits]% pour simplifier mes affaires avec \xintNewExpr + {\XINT_expr_unlock #3}{\XINT_expr_unlock #3}\endcsname }% -\let\XINT_flexpr_func_rem\XINT_expr_func_rem -\def\XINT_iiexpr_func_rem #1#2#3% +\def\XINT_iiexpr_func_sqr #1#2#3% + {\expandafter #1\expandafter #2\csname.=\xintiiSqr {\XINT_expr_unlock #3}\endcsname }% +\def\XINT_expr_func_sqrt #1#2#3% {% \expandafter #1\expandafter #2\csname .=% - \expandafter\expandafter\expandafter\xintiiRem - \expandafter\XINT_expr_twoargs - \romannumeral-`0\XINT_expr_unlock #3,\endcsname -}% -\def\XINT_expr_oneortwo #1#2#3,#4,#5.% -{% - \if\relax#5\relax\expandafter\xint_firstoftwo\else - \expandafter\xint_secondoftwo\fi - {#1{0}}{#2{\xintNum {#4}}}{#3}% + \expandafter\XINT_expr_argandopt + \romannumeral-`0\XINT_expr_unlock#3,,.\XINTinFloatSqrtdigits\XINTinFloatSqrt + \endcsname }% +\let\XINT_flexpr_func_sqrt\XINT_expr_func_sqrt +\def\XINT_iiexpr_func_sqrt #1#2#3% + {\expandafter #1\expandafter #2\csname.=\xintiiSqrt {\XINT_expr_unlock #3}\endcsname }% \def\XINT_expr_func_round #1#2#3% {% \expandafter #1\expandafter #2\csname .=% @@ -833,12 +1817,6 @@ \romannumeral-`0\XINT_expr_unlock #3,,.\endcsname }% \let\XINT_flexpr_func_round\XINT_expr_func_round -\def\XINT_iiexpr_oneortwo #1#2,#3,#4.% -{% - \if\relax#4\relax\expandafter\xint_firstoftwo\else - \expandafter\xint_secondoftwo\fi - {#1{0}}{#1{#3}}{#2}% -}% \def\XINT_iiexpr_func_round #1#2#3% {% \expandafter #1\expandafter #2\csname .=% @@ -859,226 +1837,445 @@ \expandafter\XINT_iiexpr_oneortwo\expandafter\xintiTrunc \romannumeral-`0\XINT_expr_unlock #3,,.\endcsname }% -\def\XINT_expr_argandopt #1,#2,#3.% -{% - \if\relax#3\relax\expandafter\xint_firstoftwo\else - \expandafter\xint_secondoftwo\fi - {[\XINTdigits]}{[\xintNum {#2}]}{#1}% -}% \def\XINT_expr_func_float #1#2#3% {% \expandafter #1\expandafter #2\csname .=% - \expandafter\XINTinFloat - \romannumeral-`0\expandafter\XINT_expr_argandopt - \romannumeral-`0\XINT_expr_unlock #3,,.\endcsname + \expandafter\XINT_expr_argandopt + \romannumeral-`0\XINT_expr_unlock #3,,.\XINTinFloatdigits\XINTinFloat + \endcsname }% \let\XINT_flexpr_func_float\XINT_expr_func_float -\def\XINT_expr_func_sqrt #1#2#3% +\def\XINT_expr_func_mod #1#2#3% {% \expandafter #1\expandafter #2\csname .=% - \expandafter\XINTinFloatSqrt - \romannumeral-`0\expandafter\XINT_expr_argandopt - \romannumeral-`0\XINT_expr_unlock #3,,.\endcsname + \expandafter\expandafter\expandafter\xintMod + \expandafter\XINT_expr_twoargs + \romannumeral-`0\XINT_expr_unlock #3,\endcsname }% -\let\XINT_flexpr_func_sqrt\XINT_expr_func_sqrt -\def\XINT_iiexpr_func_sqrt #1#2#3% +\def\XINT_flexpr_func_mod #1#2#3% {% - \expandafter #1\expandafter #2\csname - .=\xintiSqrt {\XINT_expr_unlock #3}\endcsname + \expandafter #1\expandafter #2\csname .=% + \expandafter\XINTinFloatMod + \romannumeral-`0\expandafter\XINT_expr_twoargs + \romannumeral-`0\XINT_expr_unlock #3,\endcsname }% -\def\XINT_expr_func_gcd #1#2#3% +\def\XINT_iiexpr_func_mod #1#2#3% {% - \expandafter #1\expandafter #2\csname - .=\xintGCDof:csv{\XINT_expr_unlock #3}\endcsname + \expandafter #1\expandafter #2\csname .=% + \expandafter\expandafter\expandafter\xintiiMod + \expandafter\XINT_expr_twoargs + \romannumeral-`0\XINT_expr_unlock #3,\endcsname }% -\let\XINT_flexpr_func_gcd\XINT_expr_func_gcd -\let\XINT_iiexpr_func_gcd\XINT_expr_func_gcd -\def\XINT_expr_func_lcm #1#2#3% +\def\XINT_expr_func_quo #1#2#3% {% - \expandafter #1\expandafter #2\csname - .=\xintLCMof:csv{\XINT_expr_unlock #3}\endcsname + \expandafter #1\expandafter #2\csname .=% + \expandafter\expandafter\expandafter\xintiQuo + \expandafter\XINT_expr_twoargs + \romannumeral-`0\XINT_expr_unlock #3,\endcsname }% -\let\XINT_flexpr_func_lcm\XINT_expr_func_lcm -\let\XINT_iiexpr_func_lcm\XINT_expr_func_lcm -\def\XINT_expr_func_max #1#2#3% +\let\XINT_flexpr_func_quo\XINT_expr_func_quo +\def\XINT_iiexpr_func_quo #1#2#3% {% - \expandafter #1\expandafter #2\csname - .=\xintMaxof:csv{\XINT_expr_unlock #3}\endcsname + \expandafter #1\expandafter #2\csname .=% + \expandafter\expandafter\expandafter\xintiiQuo + \expandafter\XINT_expr_twoargs + \romannumeral-`0\XINT_expr_unlock #3,\endcsname }% -\def\XINT_iiexpr_func_max #1#2#3% +\def\XINT_expr_func_rem #1#2#3% {% - \expandafter #1\expandafter #2\csname - .=\xintiMaxof:csv{\XINT_expr_unlock #3}\endcsname + \expandafter #1\expandafter #2\csname .=% + \expandafter\expandafter\expandafter\xintiRem + \expandafter\XINT_expr_twoargs + \romannumeral-`0\XINT_expr_unlock #3,\endcsname }% -\def\XINT_flexpr_func_max #1#2#3% +\let\XINT_flexpr_func_rem\XINT_expr_func_rem +\def\XINT_iiexpr_func_rem #1#2#3% {% - \expandafter #1\expandafter #2\csname - .=\XINTinFloatMaxof:csv{\XINT_expr_unlock #3}\endcsname + \expandafter #1\expandafter #2\csname .=% + \expandafter\expandafter\expandafter\xintiiRem + \expandafter\XINT_expr_twoargs + \romannumeral-`0\XINT_expr_unlock #3,\endcsname }% +\def\XINT_expr_func_gcd #1#2#3% + {\expandafter #1\expandafter #2\csname + .=\xintGCDof:csv{\XINT_expr_unlock #3}\endcsname }% +\let\XINT_flexpr_func_gcd\XINT_expr_func_gcd +\let\XINT_iiexpr_func_gcd\XINT_expr_func_gcd +\def\XINT_expr_func_lcm #1#2#3% + {\expandafter #1\expandafter #2\csname + .=\xintLCMof:csv{\XINT_expr_unlock #3}\endcsname }% +\let\XINT_flexpr_func_lcm\XINT_expr_func_lcm +\let\XINT_iiexpr_func_lcm\XINT_expr_func_lcm +\def\XINT_expr_func_max #1#2#3% + {\expandafter #1\expandafter #2\csname + .=\xintMaxof:csv{\XINT_expr_unlock #3}\endcsname }% +\def\XINT_iiexpr_func_max #1#2#3% + {\expandafter #1\expandafter #2\csname + .=\xintiiMaxof:csv{\XINT_expr_unlock #3}\endcsname }% +\def\XINT_flexpr_func_max #1#2#3% + {\expandafter #1\expandafter #2\csname + .=\XINTinFloatMaxof:csv{\XINT_expr_unlock #3}\endcsname }% \def\XINT_expr_func_min #1#2#3% -{% - \expandafter #1\expandafter #2\csname - .=\xintMinof:csv{\XINT_expr_unlock #3}\endcsname -}% + {\expandafter #1\expandafter #2\csname + .=\xintMinof:csv{\XINT_expr_unlock #3}\endcsname }% \def\XINT_iiexpr_func_min #1#2#3% -{% - \expandafter #1\expandafter #2\csname - .=\xintiMinof:csv{\XINT_expr_unlock #3}\endcsname -}% + {\expandafter #1\expandafter #2\csname + .=\xintiiMinof:csv{\XINT_expr_unlock #3}\endcsname }% \def\XINT_flexpr_func_min #1#2#3% -{% - \expandafter #1\expandafter #2\csname - .=\XINTinFloatMinof:csv{\XINT_expr_unlock #3}\endcsname -}% -\def\XINT_expr_func_sum #1#2#3% -{% - \expandafter #1\expandafter #2\csname - .=\xintSum:csv{\XINT_expr_unlock #3}\endcsname -}% -\def\XINT_flexpr_func_sum #1#2#3% -{% - \expandafter #1\expandafter #2\csname - .=\XINTinFloatSum:csv{\XINT_expr_unlock #3}\endcsname -}% -\def\XINT_iiexpr_func_sum #1#2#3% -{% - \expandafter #1\expandafter #2\csname - .=\xintiiSum:csv{\XINT_expr_unlock #3}\endcsname -}% -\def\XINT_expr_func_prd #1#2#3% -{% - \expandafter #1\expandafter #2\csname - .=\xintPrd:csv{\XINT_expr_unlock #3}\endcsname -}% -\def\XINT_flexpr_func_prd #1#2#3% -{% - \expandafter #1\expandafter #2\csname - .=\XINTinFloatPrd:csv{\XINT_expr_unlock #3}\endcsname -}% -\def\XINT_iiexpr_func_prd #1#2#3% -{% - \expandafter #1\expandafter #2\csname - .=\xintiiPrd:csv{\XINT_expr_unlock #3}\endcsname -}% -\let\XINT_expr_func_add\XINT_expr_func_sum -\let\XINT_expr_func_mul\XINT_expr_func_prd -\let\XINT_flexpr_func_add\XINT_flexpr_func_sum -\let\XINT_flexpr_func_mul\XINT_flexpr_func_prd -\let\XINT_iiexpr_func_add\XINT_iiexpr_func_sum -\let\XINT_iiexpr_func_mul\XINT_iiexpr_func_prd + {\expandafter #1\expandafter #2\csname + .=\XINTinFloatMinof:csv{\XINT_expr_unlock #3}\endcsname }% +\expandafter\def\csname XINT_expr_func_+\endcsname #1#2#3% + {\expandafter #1\expandafter #2\csname + .=\xintSum:csv{\XINT_expr_unlock #3}\endcsname }% +\expandafter\def\csname XINT_flexpr_func_+\endcsname #1#2#3% + {\expandafter #1\expandafter #2\csname + .=\XINTinFloatSum:csv{\XINT_expr_unlock #3}\endcsname }% +\expandafter\def\csname XINT_iiexpr_func_+\endcsname #1#2#3% + {\expandafter #1\expandafter #2\csname + .=\xintiiSum:csv{\XINT_expr_unlock #3}\endcsname }% +\expandafter\def\csname XINT_expr_func_*\endcsname #1#2#3% + {\expandafter #1\expandafter #2\csname + .=\xintPrd:csv{\XINT_expr_unlock #3}\endcsname }% +\expandafter\def\csname XINT_flexpr_func_*\endcsname #1#2#3% + {\expandafter #1\expandafter #2\csname + .=\XINTinFloatPrd:csv{\XINT_expr_unlock #3}\endcsname }% +\expandafter\def\csname XINT_iiexpr_func_*\endcsname #1#2#3% + {\expandafter #1\expandafter #2\csname + .=\xintiiPrd:csv{\XINT_expr_unlock #3}\endcsname }% \def\XINT_expr_func_? #1#2#3% -{% - \expandafter #1\expandafter #2\csname - .=\xintIsNotZero {\XINT_expr_unlock #3}\endcsname -}% + {\expandafter #1\expandafter #2\csname + .=\xintiiIsNotZero {\XINT_expr_unlock #3}\endcsname }% \let\XINT_flexpr_func_? \XINT_expr_func_? \let\XINT_iiexpr_func_? \XINT_expr_func_? \def\XINT_expr_func_! #1#2#3% -{% - \expandafter #1\expandafter #2\csname - .=\xintIsZero {\XINT_expr_unlock #3}\endcsname -}% + {\expandafter #1\expandafter #2\csname.=\xintiiIsZero {\XINT_expr_unlock #3}\endcsname }% \let\XINT_flexpr_func_! \XINT_expr_func_! \let\XINT_iiexpr_func_! \XINT_expr_func_! \def\XINT_expr_func_not #1#2#3% -{% - \expandafter #1\expandafter #2\csname - .=\xintIsZero {\XINT_expr_unlock #3}\endcsname -}% + {\expandafter #1\expandafter #2\csname.=\xintiiIsZero {\XINT_expr_unlock #3}\endcsname }% \let\XINT_flexpr_func_not \XINT_expr_func_not \let\XINT_iiexpr_func_not \XINT_expr_func_not \def\XINT_expr_func_all #1#2#3% -{% - \expandafter #1\expandafter #2\csname - .=\xintANDof:csv{\XINT_expr_unlock #3}\endcsname -}% + {\expandafter #1\expandafter #2\csname + .=\xintANDof:csv{\XINT_expr_unlock #3}\endcsname }% \let\XINT_flexpr_func_all\XINT_expr_func_all \let\XINT_iiexpr_func_all\XINT_expr_func_all \def\XINT_expr_func_any #1#2#3% -{% - \expandafter #1\expandafter #2\csname - .=\xintORof:csv{\XINT_expr_unlock #3}\endcsname -}% + {\expandafter #1\expandafter #2\csname + .=\xintORof:csv{\XINT_expr_unlock #3}\endcsname }% \let\XINT_flexpr_func_any\XINT_expr_func_any \let\XINT_iiexpr_func_any\XINT_expr_func_any \def\XINT_expr_func_xor #1#2#3% -{% - \expandafter #1\expandafter #2\csname - .=\xintXORof:csv{\XINT_expr_unlock #3}\endcsname -}% + {\expandafter #1\expandafter #2\csname + .=\xintXORof:csv{\XINT_expr_unlock #3}\endcsname }% \let\XINT_flexpr_func_xor\XINT_expr_func_xor \let\XINT_iiexpr_func_xor\XINT_expr_func_xor -\def\xintifNotZero:: #1,#2,#3,{\xintifNotZero{#1}{#2}{#3}}% +\def\xintifNotZero: #1,#2,#3,{\xintiiifNotZero{#1}{#2}{#3}}% \def\XINT_expr_func_if #1#2#3% -{% - \expandafter #1\expandafter #2\csname - .=\expandafter\xintifNotZero:: - \romannumeral-`0\XINT_expr_unlock #3,\endcsname -}% + {\expandafter #1\expandafter #2\csname + .=\expandafter\xintifNotZero:\romannumeral-`0\XINT_expr_unlock #3,\endcsname }% \let\XINT_flexpr_func_if\XINT_expr_func_if \let\XINT_iiexpr_func_if\XINT_expr_func_if -\def\xintifSgn:: #1,#2,#3,#4,{\xintifSgn{#1}{#2}{#3}{#4}}% +\def\xintifSgn: #1,#2,#3,#4,{\xintiiifSgn{#1}{#2}{#3}{#4}}% \def\XINT_expr_func_ifsgn #1#2#3% {% \expandafter #1\expandafter #2\csname - .=\expandafter\xintifSgn:: - \romannumeral-`0\XINT_expr_unlock #3,\endcsname + .=\expandafter\xintifSgn:\romannumeral-`0\XINT_expr_unlock #3,\endcsname }% \let\XINT_flexpr_func_ifsgn\XINT_expr_func_ifsgn \let\XINT_iiexpr_func_ifsgn\XINT_expr_func_ifsgn -\def\XINT_newexpr_print #1{\ifnum\xintNthElt{0}{#1}>1 - \expandafter\xint_firstoftwo - \else - \expandafter\xint_secondoftwo - \fi - {_xintListWithSep,{#1}}{\xint_firstofone#1}}% -\xintForpair #1#2 in {(fl,Float),(i,iRound0),(bool,IsTrue)}\do {% - \expandafter\def\csname XINT_new#1expr_print\endcsname - ##1{\ifnum\xintNthElt{0}{##1}>1 - \expandafter\xint_firstoftwo - \else - \expandafter\xint_secondoftwo - \fi - {_xintListWithSep,{\xintApply{_xint#2}{##1}}} - {_xint#2##1}}}% +\def\XINT_expr_func_first #1#2#3% + {\expandafter #1\expandafter #2\csname.=\expandafter\XINT_expr_func_firsta + \romannumeral-`0\XINT_expr_unlock #3,^\endcsname }% +\def\XINT_expr_func_firsta #1,#2^{#1}% +\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-`0\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}% +\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% + {\expandafter #1\expandafter #2\csname.=\xintOdd{\XINT_expr_unlock #3}\endcsname}% +\let\XINT_flexpr_func_odd\XINT_expr_func_odd +\def\XINT_iiexpr_func_odd #1#2#3% + {\expandafter #1\expandafter #2\csname.=\xintiiOdd{\XINT_expr_unlock #3}\endcsname}% +\def\XINT_expr_func_even #1#2#3% + {\expandafter #1\expandafter #2\csname.=\xintEven{\XINT_expr_unlock #3}\endcsname}% +\let\XINT_flexpr_func_even\XINT_expr_func_even +\def\XINT_iiexpr_func_even #1#2#3% + {\expandafter #1\expandafter #2\csname.=\xintiiEven{\XINT_expr_unlock #3}\endcsname}% +\def\XINT_expr_func_nuple #1#2#3% + {\expandafter #1\expandafter #2\csname .=\XINT_expr_unlock #3\endcsname }% +\let\XINT_flexpr_func_nuple\XINT_expr_func_nuple +\let\XINT_iiexpr_func_nuple\XINT_expr_func_nuple +\def\XINT_expr_func_reversed #1#2#3% + {\expandafter #1\expandafter #2\csname .=\xintReversed::csv + {\XINT_expr_unlock #3}\endcsname }% +\let\XINT_flexpr_func_reversed\XINT_expr_func_reversed +\let\XINT_iiexpr_func_reversed\XINT_expr_func_reversed +\def\xintReversed::csv #1% should be done directly, of course + {\xintListWithSep,{\xintRevWithBraces {\xintCSVtoListNonStripped{#1}}}}% +\def\xintSeqB:f:csv #1#2% + {\expandafter\XINT_seqb:f:csv \expandafter{\romannumeral0\xintraw{#2}}{#1}}% +\def\XINT_seqb:f:csv #1#2{\expandafter\XINT_seqb:f:csv_a\romannumeral-`0#2#1!}% +\def\XINT_seqb:f:csv_a #1#2;#3;#4!{% + \expandafter\xint_gobble_i\romannumeral-`0% + \xintifCmp {#3}{#4}\XINT_seqb:f:csv_bl\XINT_seqb:f:csv_be\XINT_seqb:f:csv_bg + #1{#3}{#4}{}{#2}}% +\def\XINT_seqb:f:csv_be #1#2#3#4#5{,#2}% +\def\XINT_seqb:f:csv_bl #1{\if #1p\expandafter\XINT_seqb:f:csv_pa\else + \xint_afterfi{\expandafter,\xint_gobble_iv}\fi }% +\def\XINT_seqb:f:csv_pa #1#2#3#4{\expandafter\XINT_seqb:f:csv_p\expandafter + {\romannumeral0\xintadd{#4}{#1}}{#2}{#3,#1}{#4}}% +\def\XINT_seqb:f:csv_p #1#2% +{% + \xintifCmp {#1}{#2}\XINT_seqb:f:csv_pa\XINT_seqb:f:csv_pb\XINT_seqb:f:csv_pc + {#1}{#2}% +}% +\def\XINT_seqb:f:csv_pb #1#2#3#4{#3,#1}% +\def\XINT_seqb:f:csv_pc #1#2#3#4{#3}% +\def\XINT_seqb:f:csv_bg #1{\if #1n\expandafter\XINT_seqb:f:csv_na\else + \xint_afterfi{\expandafter,\xint_gobble_iv}\fi }% +\def\XINT_seqb:f:csv_na #1#2#3#4{\expandafter\XINT_seqb:f:csv_n\expandafter + {\romannumeral0\xintadd{#4}{#1}}{#2}{#3,#1}{#4}}% +\def\XINT_seqb:f:csv_n #1#2% +{% + \xintifCmp {#1}{#2}\XINT_seqb:f:csv_nc\XINT_seqb:f:csv_nb\XINT_seqb:f:csv_na + {#1}{#2}% +}% +\def\XINT_seqb:f:csv_nb #1#2#3#4{#3,#1}% +\def\XINT_seqb:f:csv_nc #1#2#3#4{#3}% +\def\xintiiSeqb:f:csv #1#2% + {\expandafter\XINT_iiseqb:f:csv \expandafter{\romannumeral-`0#2}{#1}}% +\def\XINT_iiseqb:f:csv #1#2{\expandafter\XINT_iiseqb:f:csv_a\romannumeral-`0#2#1!}% +\def\XINT_iiseqb:f:csv_a #1#2;#3;#4!{% + \expandafter\xint_gobble_i\romannumeral-`0% + \xintSgnFork{\XINT_Cmp {#3}{#4}}% + \XINT_iiseqb:f:csv_bl\XINT_seqb:f:csv_be\XINT_iiseqb:f:csv_bg + #1{#3}{#4}{}{#2}}% +\def\XINT_iiseqb:f:csv_bl #1{\if #1p\expandafter\XINT_iiseqb:f:csv_pa\else + \xint_afterfi{\expandafter,\xint_gobble_iv}\fi }% +\def\XINT_iiseqb:f:csv_pa #1#2#3#4{\expandafter\XINT_iiseqb:f:csv_p\expandafter + {\romannumeral0\xintiiadd{#4}{#1}}{#2}{#3,#1}{#4}}% +\def\XINT_iiseqb:f:csv_p #1#2% +{% + \xintSgnFork{\XINT_Cmp {#1}{#2}}% + \XINT_iiseqb:f:csv_pa\XINT_iiseqb:f:csv_pb\XINT_iiseqb:f:csv_pc {#1}{#2}% +}% +\def\XINT_iiseqb:f:csv_pb #1#2#3#4{#3,#1}% +\def\XINT_iiseqb:f:csv_pc #1#2#3#4{#3}% +\def\XINT_iiseqb:f:csv_bg #1{\if #1n\expandafter\XINT_iiseqb:f:csv_na\else + \xint_afterfi{\expandafter,\xint_gobble_iv}\fi }% +\def\XINT_iiseqb:f:csv_na #1#2#3#4{\expandafter\XINT_iiseqb:f:csv_n\expandafter + {\romannumeral0\xintiiadd{#4}{#1}}{#2}{#3,#1}{#4}}% +\def\XINT_iiseqb:f:csv_n #1#2% +{% + \xintSgnFork{\XINT_Cmp {#1}{#2}}% + \XINT_seqb:f:csv_nc\XINT_seqb:f:csv_nb\XINT_iiseqb:f:csv_na {#1}{#2}% +}% +\def\XINTinFloatSeqB:f:csv #1#2{\expandafter\XINT_flseqb:f:csv \expandafter + {\romannumeral0\XINTinfloat [\XINTdigits]{#2}}{#1}}% +\def\XINT_flseqb:f:csv #1#2{\expandafter\XINT_flseqb:f:csv_a\romannumeral-`0#2#1!}% +\def\XINT_flseqb:f:csv_a #1#2;#3;#4!{% + \expandafter\xint_gobble_i\romannumeral-`0% + \xintifCmp {#3}{#4}\XINT_flseqb:f:csv_bl\XINT_seqb:f:csv_be\XINT_flseqb:f:csv_bg + #1{#3}{#4}{}{#2}}% +\def\XINT_flseqb:f:csv_bl #1{\if #1p\expandafter\XINT_flseqb:f:csv_pa\else + \xint_afterfi{\expandafter,\xint_gobble_iv}\fi }% +\def\XINT_flseqb:f:csv_pa #1#2#3#4{\expandafter\XINT_flseqb:f:csv_p\expandafter + {\romannumeral0\XINTinfloatadd{#4}{#1}}{#2}{#3,#1}{#4}}% +\def\XINT_flseqb:f:csv_p #1#2% +{% + \xintifCmp {#1}{#2}% + \XINT_flseqb:f:csv_pa\XINT_flseqb:f:csv_pb\XINT_flseqb:f:csv_pc {#1}{#2}% +}% +\def\XINT_flseqb:f:csv_pb #1#2#3#4{#3,#1}% +\def\XINT_flseqb:f:csv_pc #1#2#3#4{#3}% +\def\XINT_flseqb:f:csv_bg #1{\if #1n\expandafter\XINT_flseqb:f:csv_na\else + \xint_afterfi{\expandafter,\xint_gobble_iv}\fi }% +\def\XINT_flseqb:f:csv_na #1#2#3#4{\expandafter\XINT_flseqb:f:csv_n\expandafter + {\romannumeral0\XINTinfloatadd{#4}{#1}}{#2}{#3,#1}{#4}}% +\def\XINT_flseqb:f:csv_n #1#2% +{% + \xintifCmp {#1}{#2}% + \XINT_seqb:f:csv_nc\XINT_seqb:f:csv_nb\XINT_flseqb:f:csv_na {#1}{#2}% +}% +\def\xintApply::csv #1#2% + {\expandafter\XINT_applyon::_a\expandafter {\romannumeral-`0#2}{#1}}% +\def\XINT_applyon::_a #1#2{\XINT_applyon::_b {#2}{}#1,,}% +\def\XINT_applyon::_b #1#2#3,{\expandafter\XINT_applyon::_c \romannumeral-`0#3,{#1}{#2}}% +\def\XINT_applyon::_c #1{\if #1,\expandafter\XINT_applyon::_end + \else\expandafter\XINT_applyon::_d\fi #1}% +\def\XINT_applyon::_d #1,#2{\expandafter\XINT_applyon::_e\romannumeral-`0#2{#1},{#2}}% +\def\XINT_applyon::_e #1,#2#3{\XINT_applyon::_b {#2}{#3, #1}}% +\def\XINT_applyon::_end #1,#2#3{\xint_secondoftwo #3}% +\def\xintApply:::csv #1#2#3% + {\expandafter\XINT_applyon:::_a\expandafter{\romannumeral-`0#2}{#1}{#3}}% +\def\XINT_applyon:::_a #1#2#3{\XINT_applyon:::_b {#2}{#3}{}#1,,}% +\def\XINT_applyon:::_b #1#2#3#4,% + {\expandafter\XINT_applyon:::_c \romannumeral-`0#4,{#1}{#2}{#3}}% +\def\XINT_applyon:::_c #1{\if #1,\expandafter\XINT_applyon:::_end + \else\expandafter\XINT_applyon:::_d\fi #1}% +\def\XINT_applyon:::_d #1,#2#3% + {\expandafter\XINT_applyon:::_e\expandafter + {\romannumeral-`0\xintApply::csv {#2{#1}}{#3}},{#2}{#3}}% +\def\XINT_applyon:::_e #1,#2#3#4{\XINT_applyon:::_b {#2}{#3}{#4, #1}}% +\def\XINT_applyon:::_end #1,#2#3#4{\xint_secondoftwo #4}% +\def\XINT_expr_RApply::csv #1#2#3#4% + {~xintApply::csv{~expandafter#1~xint_exchangetwo_keepbraces{#4}}{#3}}% +\def\XINT_expr_LApply::csv #1#2#3#4{~xintApply::csv{#1{#3}}{#4}}% +\def\XINT_expr_RLApply:::csv #1#2{~xintApply:::csv{#1}}% +\catcode`~ 12 % by the way, catcode is set to 3 in \XINTsetupcatcodes +\catcode`$ 12 % $ +\def\XINT_xptwo_getab_b #1#2!#3% + {\expandafter\XINT_xptwo_getab_c\romannumeral-`0#3!#1{#1#2}}% +\def\XINT_xptwo_getab_c #1#2!#3#4#5#6{#1#3{#5}{#6}{#1#2}{#4}}% +\def\xint_ddfork #1$$#2#3\krof {#2}% +\def\XINT_NEfork #1#2{\xint_ddfork + #1#2\XINT_expr_RLApply:::csv + #1$\XINT_expr_RApply::csv% $ + $#2\XINT_expr_LApply::csv% $ + $${\XINT_NEfork_nn #1#2}% + \krof }% +\def\XINT_NEfork_nn #1#2#3#4{% + \if #1##\xint_dothis{#3}\fi + \if #1~\xint_dothis{#3}\fi + \if #2##\xint_dothis{#3}\fi + \if #2~\xint_dothis{#3}\fi + \xint_orthat {\csname #4NE\endcsname }% + }% +\def\XINT_NEfork_one #1#2!#3#4#5#6{% + \if ###1\xint_dothis {#3}\fi + \if ~#1\xint_dothis {#3}\fi + \if $#1\xint_dothis {~xintApply::csv{#3#5}}\fi %$ + \xint_orthat {\csname #4NE\endcsname #6}{#1#2}% +}% \toks0 {}% -\xintFor #1 in {Bool,Toggle,Floor,Ceil,iRound,Round,iTrunc,Trunc,TFrac,% - Lt,Gt,Eq,AND,OR,IsNotZero,IsZero,ifNotZero,ifSgn,% - Irr,Num,Abs,Sgn,Opp,Quo,Rem,Add,Sub,Mul,Sqr,Div,Pow,Fac,fE,iSqrt,% - iiAdd,iiSub,iiMul,iiSqr,iiPow,iiQuo,iiRem,iiSgn,iiAbs,iiOpp,iE}\do +\xintFor #1 in {DivTrunc,iiDivTrunc,iiDivRound,Mod,iiMod,iRound,Round,iTrunc,Trunc,% + Lt,Gt,Eq,LtorEq,GtorEq,Neq,AND,OR,XOR,iQuo,iRem,Add,Sub,Mul,Div,Pow,E,% + iiAdd,iiSub,iiMul,iiPow,iiQuo,iiRem,iiE,SeqA::csv,iiSeqA::csv}\do {\toks0 - \expandafter{\the\toks0\expandafter\def\csname xint#1\endcsname {_xint#1}}}% -\xintFor #1 in {,Sqrt,Add,Sub,Mul,Div,Power,fE,Frac}\do - {\toks0 - \expandafter{\the\toks0\expandafter\def\csname XINTinFloat#1\endcsname - {_XINTinFloat#1}}}% -\xintFor #1 in {GCDof,LCMof,Maxof,Minof,ANDof,ORof,XORof,Sum,Prd,% - iMaxof,iMinof,iiSum,iiPrd}\do - {\toks0 - \expandafter{\the\toks0\expandafter\def\csname xint#1:csv\endcsname - ####1{_xint#1{\xintCSVtoListNonStripped {####1}}}}}% + \expandafter{\the\toks0 + \expandafter\let\csname xint#1NE\expandafter\endcsname\csname xint#1\endcsname + \expandafter\def\csname xint#1\endcsname ####1####2{% + \expandafter\XINT_NEfork + \romannumeral-`0\expandafter\XINT_xptwo_getab_b + \romannumeral-`0####2!{####1}{~xint#1}{xint#1}}% + }% +}% +\xintFor #1 in {Num,Irr,Abs,iiAbs,Sgn,iiSgn,TFrac,Floor,iFloor,Ceil,iCeil,% + Sqr,iiSqr,iSqrt,iiIsZero,iiIsNotZero,iiifNotZero,iiifSgn,Odd,Even,iiOdd,iiEven,% + Opp,iiOpp,iiifZero,Fac,iFac,Bool,Toggle}\do +{\toks0 + \expandafter{\the\toks0 + \expandafter\let\csname xint#1NE\expandafter\endcsname\csname xint#1\endcsname + \expandafter\def\csname xint#1\endcsname ####1{% + \expandafter\XINT_NEfork_one\romannumeral-`0####1!{~xint#1}{xint#1}{}{}}% + }% +}% +\xintFor #1 in {Add,Sub,Mul,Div,Power,E,Mod,SeqA::csv}\do +{\toks0 + \expandafter{\the\toks0 + \expandafter\let\csname XINTinFloat#1NE\expandafter\endcsname + \csname XINTinFloat#1\endcsname + \expandafter\def\csname XINTinFloat#1\endcsname ####1####2{% + \expandafter\XINT_NEfork + \romannumeral-`0\expandafter\XINT_xptwo_getab_b + \romannumeral-`0####2!{####1}{~XINTinFloat#1}{XINTinFloat#1}}% + }% +}% +\toks0 + \expandafter{\the\toks0 + \let\xintSeqB::csvNE\xintSeqB::csv + \def\xintSeqB::csv ##1##2{% + \expandafter\XINT_NEfork + \romannumeral-`0\expandafter\XINT_xptwo_getab_b + \romannumeral-`0##2!{##1}{$noexpand$xintSeqB:f:csv}{xintSeqB::csv}}% + \let\xintiiSeqB::csvNE\xintiiSeqB::csv + \def\xintiiSeqB::csv ##1##2{% + \expandafter\XINT_NEfork + \romannumeral-`0\expandafter\XINT_xptwo_getab_b + \romannumeral-`0##2!{##1}{$noexpand$xintiiSeqB:f:csv}{xintiiSeqB::csv}}% + \let\XINTinFloatSeqB::csvNE\XINTinFloatSeqB::csv + \def\XINTinFloatSeqB::csv ##1##2{% + \expandafter\XINT_NEfork + \romannumeral-`0\expandafter\XINT_xptwo_getab_b + \romannumeral-`0##2!{##1}{$noexpand$XINTinFloatSeqB:f:csv}{XINTinFloatSeqB::csv}}% + \let\xintSeq::csvNE\xintSeq::csv + \def\xintSeq::csv ##1##2{% + \expandafter\XINT_NEfork + \romannumeral-`0\expandafter\XINT_xptwo_getab_b + \romannumeral-`0##2!{##1}{$noexpand$xintSeq::csv}{xintSeq::csv}}% + \let\xintiiSeq::csvNE\xintiiSeq::csv + \def\xintiiSeq::csv ##1##2{% + \expandafter\XINT_NEfork + \romannumeral-`0\expandafter\XINT_xptwo_getab_b + \romannumeral-`0##2!{##1}{$noexpand$xintiiSeq::csv}{xintiiSeq::csv}}% + \let\XINTinFloatSeq::csvNE\XINTinFloatSeq::csv + \def\XINTinFloatSeq::csv ##1##2{% + \expandafter\XINT_NEfork + \romannumeral-`0\expandafter\XINT_xptwo_getab_b + \romannumeral-`0##2!{##1}{$noexpand$XINTinFloatSeq::csv}{XINTinFloatSeq::csv}}% + \let\XINTinFloatFracNE\XINTinFloatFrac + \def\XINTinFloatFrac ##1{\expandafter\XINT_NEfork_one\romannumeral-`0##1!% + {~XINTinFloatFrac}{XINTinFloatFrac}{}{}}% + \let\XINTinFloatdigitsNE\XINTinFloatdigits + \def\XINTinFloatdigits ##1{\expandafter\XINT_NEfork_one\romannumeral-`0##1!% + {~XINTinFloatdigits}{XINTinFloatdigits}{}{}}% + \let\XINTinFloatSqrtdigitsNE\XINTinFloatSqrtdigits + \def\XINTinFloatSqrtdigits ##1{\expandafter\XINT_NEfork_one\romannumeral-`0##1!% + {~XINTinFloatSqrtdigits}{XINTinFloatSqrtdigits}{}{}}% + \let\XINTinFloatNE\XINTinFloat + \def\XINTinFloat [##1]##2{% not ultimately general, but got tired + \expandafter\XINT_NEfork_one + \romannumeral-`0##2!{~XINTinFloat[##1]}{XINTinFloat}{}{[##1]}}% + \let\XINTinFloatSqrtNE\XINTinFloatSqrt + \def\XINTinFloatSqrt [##1]##2{% + \expandafter\XINT_NEfork_one + \romannumeral-`0##2!{~XINTinFloatSqrt[##1]}{XINTinFloatSqrt}{}{[##1]}}% +}% +\xintFor #1 in {ANDof,ORof,XORof,iiMaxof,iiMinof,iiSum,iiPrd, + GCDof,LCMof,Sum,Prd,Maxof,Minof}\do +{\toks0 + \expandafter{\the\toks0 \expandafter\def\csname xint#1:csv\endcsname {~xint#1:csv}}% +}% \xintFor #1 in {Maxof,Minof,Sum,Prd}\do - {\toks0 - \expandafter{\the\toks0\expandafter\def\csname XINTinFloat#1:csv\endcsname - ####1{_XINTinFloat#1{\xintCSVtoListNonStripped {####1}}}}}% -\expandafter\def\expandafter\XINT_expr_protect\expandafter{\the\toks0 - \def\XINTdigits {_XINTdigits}% - \def\XINT_expr_print ##1{\expandafter\XINT_newexpr_print\expandafter - {\romannumeral0\xintcsvtolistnonstripped{\XINT_expr_unlock ##1}}}% - \def\XINT_flexpr_print ##1{\expandafter\XINT_newflexpr_print\expandafter - {\romannumeral0\xintcsvtolistnonstripped{\XINT_expr_unlock ##1}}}% - \def\XINT_iexpr_print ##1{\expandafter\XINT_newiexpr_print\expandafter - {\romannumeral0\xintcsvtolistnonstripped{\XINT_expr_unlock ##1}}}% - \def\XINT_boolexpr_print ##1{\expandafter\XINT_newboolexpr_print\expandafter - {\romannumeral0\xintcsvtolistnonstripped{\XINT_expr_unlock ##1}}}% +{\toks0 + \expandafter{\the\toks0 + \expandafter\def\csname XINTinFloat#1:csv\endcsname {~XINTinFloat#1:csv}}% +}% +\expandafter\def\expandafter\XINT_expr_redefinemacros\expandafter + {\the\toks0 + \def\XINT_flexpr_noopt {\expandafter\XINT_flexpr_withopt_b\expandafter-% + \romannumeral0\xintbarefloateval }% + \def\XINT_flexpr_withopt_b ##1##2% + {\expandafter\XINT_flexpr_wrap\csname .;##1.=\XINT_expr_unlock ##2\endcsname }% + \def\XINT_expr_unlock_sp ##1.;##2##3.=##4!{\if -##2\expandafter\xint_firstoftwo + \else\expandafter\xint_secondoftwo\fi \XINTdigits{{##2##3}}{##4}}% + \def\XINT_expr_print ##1{\expandafter\xintSPRaw::csv\expandafter + {\romannumeral-`0\XINT_expr_unlock ##1}}% + \def\XINT_iiexpr_print ##1{\expandafter\xintCSV::csv\expandafter + {\romannumeral-`0\XINT_expr_unlock ##1}}% + \def\XINT_boolexpr_print ##1{\expandafter\xintIsTrue::csv\expandafter + {\romannumeral-`0\XINT_expr_unlock ##1}}% + \def\xintCSV::csv {~xintCSV::csv }% spaces to separate from possible catcode 11 + \def\xintSPRaw::csv {~xintSPRaw::csv }% stuff after + \def\xintPFloat::csv {~xintPFloat::csv }% + \def\xintIsTrue::csv {~xintIsTrue::csv }% + \def\xintRound::csv {~xintRound::csv }% + \def\xintReversed::csv {~xintReversed::csv }% + \def\xintListSel:csv {~xintListSel:csv }% }% \toks0 {}% \def\xintNewExpr {\xint_NewExpr\xinttheexpr }% \def\xintNewFloatExpr {\xint_NewExpr\xintthefloatexpr }% \def\xintNewIExpr {\xint_NewExpr\xinttheiexpr }% -\let\xintNewNumExpr\xintNewIExpr \def\xintNewIIExpr {\xint_NewExpr\xinttheiiexpr }% \def\xintNewBoolExpr {\xint_NewExpr\xinttheboolexpr }% +\def\XINT_newexpr_finish #1>{\noexpand\romannumeral-`0}% \def\xint_NewExpr #1#2[#3]% {% \begingroup @@ -1095,38 +2292,32 @@ \or \toks0 {\xdef #2##1##2##3##4##5##6##7##8##9}% \fi \xintexprSafeCatcodes - \escapechar92 \XINT_NewExpr #1% }% -\catcode`* 13 -\def\XINT_NewExpr #1#2% -{% - \def\XINT_tmpa ##1##2##3##4##5##6##7##8##9{#2}% - \XINT_expr_protect - \lccode`*=`_ \lowercase {\def*}{!noexpand!}% - \catcode`_ 13 \catcode`: 11 - \endlinechar -1 % 1.09i, 2013/12/18 not sure why I had that? removed. - % 2014/02/13: you idiot, if not then spurious extra ending space - % token makes impossible nesting of created macros! - \everyeof {\noexpand }% - \edef\XINT_tmpb ##1##2##3##4##5##6##7##8##9% - {\scantokens - \expandafter{\romannumeral-`0#1% - \XINT_tmpa {####1}{####2}{####3}% - {####4}{####5}{####6}% - {####7}{####8}{####9}% - \relax}}% - \lccode`*=`\$ \lowercase {\def*}{####}% - \catcode`\$ 13 \catcode`! 0 \catcode`_ 11 % - \the\toks0 - {\scantokens\expandafter{\expandafter - \XINT_newexpr_setprefix\meaning\XINT_tmpb}}% +\catcode`~ 13 \catcode`@ 14 \catcode`\% 6 \catcode`# 12 \catcode`$ 11 @ $ +\def\XINT_NewExpr %1%2@ +{@ + \def\XINT_tmpa %%1%%2%%3%%4%%5%%6%%7%%8%%9{%2}@ + \XINT_expr_redefinemacros + \def~{$noexpand$}@ vvv v^^e9rifier si vraiment besoin pour ^ et ! + \catcode`: 11 \catcode`_ 11 @ \catcode`^ 11 \catcode`! 11 + \catcode`# 12 \catcode`~ 13 \escapechar 126 + \endlinechar -1 \everyeof {\noexpand }@ + \edef\XINT_tmpb + {\scantokens\expandafter + {\romannumeral-`0\expandafter%1\XINT_tmpa {#1}{#2}{#3}{#4}{#5}{#6}{#7}{#8}{#9}\relax}@ + }@ + \escapechar 92 \catcode`# 6 \catcode`$ 0 @ $ + \the\toks0 + {\scantokens\expandafter{\expandafter\XINT_newexpr_finish\meaning\XINT_tmpb}}@ \endgroup -}% +}@ +\catcode`% 14 \let\xintexprRestoreCatcodes\empty \def\xintexprSafeCatcodes -{% for end user. +{% \edef\xintexprRestoreCatcodes {% + \catcode59=\the\catcode59 % ; \catcode34=\the\catcode34 % " \catcode63=\the\catcode63 % ? \catcode124=\the\catcode124 % | @@ -1149,7 +2340,8 @@ \catcode44=\the\catcode44 % , \catcode61=\the\catcode61 % = \catcode32=\the\catcode32\relax % space - }% it's hard to know where to stop... + }% + \catcode59=12 % ; \catcode34=12 % " \catcode63=12 % ? \catcode124=12 % | -- cgit v1.2.3