summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/l3kernel/l3fp-basics.dtx
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2018-02-23 21:54:14 +0000
committerKarl Berry <karl@freefriends.org>2018-02-23 21:54:14 +0000
commit87d871a3d83784d48b71fa3712b9f525bfc710d2 (patch)
treef12f9ffdc697b5af9ee14c06874ec0e2f72c9f94 /Master/texmf-dist/source/latex/l3kernel/l3fp-basics.dtx
parentccc63194ce7813106830c8a8755c54d89de831b4 (diff)
l3 (22feb18)
git-svn-id: svn://tug.org/texlive/trunk@46720 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/l3kernel/l3fp-basics.dtx')
-rw-r--r--Master/texmf-dist/source/latex/l3kernel/l3fp-basics.dtx72
1 files changed, 70 insertions, 2 deletions
diff --git a/Master/texmf-dist/source/latex/l3kernel/l3fp-basics.dtx b/Master/texmf-dist/source/latex/l3kernel/l3fp-basics.dtx
index 8f7e365eeec..8a0f18da382 100644
--- a/Master/texmf-dist/source/latex/l3kernel/l3fp-basics.dtx
+++ b/Master/texmf-dist/source/latex/l3kernel/l3fp-basics.dtx
@@ -1,6 +1,6 @@
% \iffalse meta-comment
%
-%% File: l3fp-basics.dtx Copyright (C) 2011-2014,2016,2017 The LaTeX3 Project
+%% File: l3fp-basics.dtx Copyright (C) 2011-2014,2016-2018 The LaTeX3 Project
%
% It may be distributed and/or modified under the conditions of the
% LaTeX Project Public License (LPPL), either version 1.3c of this
@@ -38,7 +38,7 @@
% {latex-team@latex-project.org}^^A
% }^^A
% }
-% \date{Released 2017/12/16}
+% \date{Released 2018/02/21}
%
% \maketitle
%
@@ -2068,6 +2068,74 @@
% \end{macrocode}
% \end{macro}
%
+% \subsection{Operations on tuples}
+%
+% \begin{macro}[EXP]{\@@_tuple_set_sign_o:w}
+% \begin{macro}[EXP]{\@@_tuple_set_sign_aux_o:Nnw, \@@_tuple_set_sign_aux_o:w}
+% Two cases: |abs(|\meta{tuple}|)| for which |#1| is $0$ (invalid for
+% tuples) and |-|\meta{tuple} for which |#1| is $2$. In that case,
+% map over all items in the tuple an auxiliary that dispatches to the
+% type-appropriate sign-flipping function.
+% \begin{macrocode}
+\cs_new:Npn \@@_tuple_set_sign_o:w #1
+ {
+ \if_meaning:w 2 #1
+ \exp_after:wN \@@_tuple_set_sign_aux_o:Nnw
+ \fi:
+ \@@_invalid_operation_o:nw { abs }
+ }
+\cs_new:Npn \@@_tuple_set_sign_aux_o:Nnw #1#2#3 @
+ { \@@_tuple_map_o:nw \@@_tuple_set_sign_aux_o:w #3 }
+\cs_new:Npn \@@_tuple_set_sign_aux_o:w #1#2 ;
+ {
+ \@@_change_func_type:NNN #1 \@@_set_sign_o:w
+ \@@_parse_apply_unary_error:NNw
+ 2 #1 #2 ; @
+ }
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}[EXP]{\@@_*_tuple_o:ww, \@@_tuple_*_o:ww, \@@_tuple_/_o:ww}
+% For \meta{number}|*|\meta{tuple} and \meta{tuple}|*|\meta{number}
+% and \meta{tuple}|/|\meta{number}, loop through the \meta{tuple} some
+% code that multiplies or divides by the appropriate \meta{number}.
+% Importantly we need to dispatch according to the type, and we make
+% sure to apply the operator in the correct order.
+% \begin{macrocode}
+\cs_new:cpn { @@_*_tuple_o:ww } #1 ;
+ { \@@_tuple_map_o:nw { \@@_binary_type_o:Nww * #1 ; } }
+\cs_new:cpn { @@_tuple_*_o:ww } #1 ; #2 ;
+ { \@@_tuple_map_o:nw { \@@_binary_rev_type_o:Nww * #2 ; } #1 ; }
+\cs_new:cpn { @@_tuple_/_o:ww } #1 ; #2 ;
+ { \@@_tuple_map_o:nw { \@@_binary_rev_type_o:Nww / #2 ; } #1 ; }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}[EXP]{\@@_tuple_+_tuple_o:ww, \@@_tuple_-_tuple_o:ww}
+% Check the two tuples have the same number of items and map through
+% these a helper that dispatches appropriately depending on the types.
+% This means |(1,2)+((1,1),2)| gives |(nan,4)|.
+% \begin{macrocode}
+\cs_set_protected:Npn \@@_tmp:w #1
+ {
+ \cs_new:cpn { @@_tuple_#1_tuple_o:ww }
+ \s_@@_tuple \@@_tuple_chk:w ##1 ;
+ \s_@@_tuple \@@_tuple_chk:w ##2 ;
+ {
+ \int_compare:nNnTF
+ { \@@_array_count:n {##1} } = { \@@_array_count:n {##2} }
+ { \@@_tuple_mapthread_o:nww { \@@_binary_type_o:Nww #1 } }
+ { \@@_invalid_operation_o:nww #1 }
+ \s_@@_tuple \@@_tuple_chk:w {##1} ;
+ \s_@@_tuple \@@_tuple_chk:w {##2} ;
+ }
+ }
+\@@_tmp:w +
+\@@_tmp:w -
+% \end{macrocode}
+% \end{macro}
+%
% \begin{macrocode}
%</initex|package>
% \end{macrocode}