[latex3-commits] [git/LaTeX3-latex3-latex3] master: Make "and" and "or" work for tuples (see #438 and see last commit) (71a987b)
Bruno Le Floch
bruno at le-floch.fr
Sun Feb 25 05:17:56 CET 2018
Repository : https://github.com/latex3/latex3
On branch : master
Link : https://github.com/latex3/latex3/commit/71a987bae12bc5df3c8fa6ec1da5b0f957e245a8
>---------------------------------------------------------------
commit 71a987bae12bc5df3c8fa6ec1da5b0f957e245a8
Author: Bruno Le Floch <bruno at le-floch.fr>
Date: Sat Feb 24 23:17:56 2018 -0500
Make "and" and "or" work for tuples (see #438 and see last commit)
>---------------------------------------------------------------
71a987bae12bc5df3c8fa6ec1da5b0f957e245a8
l3kernel/l3fp-aux.dtx | 4 ++++
l3kernel/l3fp-logic.dtx | 19 ++++++++++++++++---
l3kernel/testfiles/m3expl001.luatex.tlg | 7 +++++++
l3kernel/testfiles/m3expl001.ptex.tlg | 7 +++++++
l3kernel/testfiles/m3expl001.tlg | 7 +++++++
l3kernel/testfiles/m3expl001.uptex.tlg | 7 +++++++
l3kernel/testfiles/m3expl001.xetex.tlg | 7 +++++++
l3kernel/testfiles/m3expl003.luatex.tlg | 7 +++++++
l3kernel/testfiles/m3expl003.ptex.tlg | 7 +++++++
l3kernel/testfiles/m3expl003.tlg | 7 +++++++
l3kernel/testfiles/m3expl003.uptex.tlg | 7 +++++++
l3kernel/testfiles/m3expl003.xetex.tlg | 7 +++++++
l3kernel/testfiles/m3fp-logic002.lvt | 8 ++++++++
l3kernel/testfiles/m3fp-logic002.tlg | 8 ++++++++
14 files changed, 106 insertions(+), 3 deletions(-)
diff --git a/l3kernel/l3fp-aux.dtx b/l3kernel/l3fp-aux.dtx
index 2c63887..3a3a9c2 100644
--- a/l3kernel/l3fp-aux.dtx
+++ b/l3kernel/l3fp-aux.dtx
@@ -630,6 +630,7 @@
% \end{macro}
% \end{macro}
%
+% \begin{macro}[EXP]{\@@_exp_after_tuple_o:w}
% \begin{macro}[EXP]{\@@_exp_after_tuple_f:nw, \@@_exp_after_array_f:w}
% The loop works by using the |n| argument of
% \cs{@@_exp_after_any_f:nw} to place the loop macro after the next
@@ -642,6 +643,8 @@
% \cs{s_@@_stop}
% \end{quote}
% \begin{macrocode}
+\cs_new:Npn \@@_exp_after_tuple_o:w
+ { \@@_exp_after_tuple_f:nw { \exp_after:wN \exp_stop_f: } }
\cs_new:Npn \@@_exp_after_tuple_f:nw #1 \s_@@_tuple \@@_tuple_chk:w #2 ;
{
\exp_after:wN \s_@@_tuple
@@ -657,6 +660,7 @@
{ \@@_exp_after_any_f:nw { \@@_exp_after_array_f:w } }
% \end{macrocode}
% \end{macro}
+% \end{macro}
%
% \subsection{Packing digits}
%
diff --git a/l3kernel/l3fp-logic.dtx b/l3kernel/l3fp-logic.dtx
index 35e0c98..2e33b9f 100644
--- a/l3kernel/l3fp-logic.dtx
+++ b/l3kernel/l3fp-logic.dtx
@@ -528,8 +528,8 @@
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}[EXP]+\@@_&_o:ww+
-% \begin{macro}[EXP]+\@@_|_o:ww+
+% \begin{macro}[EXP]{\@@_&_o:ww, \@@_tuple_&_o:ww, \@@_&_tuple_o:ww, \@@_tuple_&_tuple_o:ww}
+% \begin{macro}[EXP]{\@@_|_o:ww, \@@_tuple_|_o:ww, \@@_|_tuple_o:ww, \@@_tuple_|_tuple_o:ww}
% \begin{macro}[EXP]{\@@_and_return:wNw}
% For \texttt{and}, if the first number is zero, return it (with the
% same sign). Otherwise, return the second one. For \texttt{or}, the
@@ -548,9 +548,22 @@
\fi:
\@@_exp_after_o:w
}
+ \cs_new:Npn \@@_&_tuple_o:ww #1 \s_@@ \@@_chk:w #2#3;
+ {
+ \if_meaning:w 0 #2 #1
+ \@@_and_return:wNw \s_@@ \@@_chk:w #2#3;
+ \fi:
+ \@@_exp_after_tuple_o:w
+ }
+ \cs_new:Npn \@@_tuple_&_o:ww #1; { \@@_exp_after_o:w }
+ \cs_new:Npn \@@_tuple_&_tuple_o:ww #1; { \@@_exp_after_tuple_o:w }
\cs_new:Npn \@@_|_o:ww { \@@_&_o:ww \else: }
+ \cs_new:Npn \@@_|_tuple_o:ww { \@@_&_tuple_o:ww \else: }
+ \cs_new:Npn \@@_tuple_|_o:ww #1; #2; { \@@_exp_after_tuple_o:w #1; }
+ \cs_new:Npn \@@_tuple_|_tuple_o:ww #1; #2; { \@@_exp_after_tuple_o:w #1; }
\group_end:
-\cs_new:Npn \@@_and_return:wNw #1; \fi: #2#3; { \fi: #2 #1; }
+\cs_new:Npn \@@_and_return:wNw #1; \fi: #2;
+ { \fi: \@@_exp_after_o:w #1; }
% \end{macrocode}
% \end{macro}
% \end{macro}
diff --git a/l3kernel/testfiles/m3expl001.luatex.tlg b/l3kernel/testfiles/m3expl001.luatex.tlg
index 3634264..fe6a3b1 100644
--- a/l3kernel/testfiles/m3expl001.luatex.tlg
+++ b/l3kernel/testfiles/m3expl001.luatex.tlg
@@ -3653,6 +3653,7 @@ Defining \__fp_change_func_type_chk:NNN on line ...
Defining \__fp_exp_after_any_f:Nnw on line ...
Defining \__fp_exp_after_any_f:nw on line ...
Defining \__fp_exp_after_stop_f:nw on line ...
+Defining \__fp_exp_after_tuple_o:w on line ...
Defining \__fp_exp_after_tuple_f:nw on line ...
Defining \__fp_exp_after_array_f:w on line ...
Defining \c__fp_leading_shift_int on line ...
@@ -4091,7 +4092,13 @@ Defining \__fp_minmax_break_o:w on line ...
Defining \__fp_not_o:w on line ...
Defining \__fp_tuple_not_o:w on line ...
Defining \__fp_&_o:ww on line ...
+Defining \__fp_&_tuple_o:ww on line ...
+Defining \__fp_tuple_&_o:ww on line ...
+Defining \__fp_tuple_&_tuple_o:ww on line ...
Defining \__fp_|_o:ww on line ...
+Defining \__fp_|_tuple_o:ww on line ...
+Defining \__fp_tuple_|_o:ww on line ...
+Defining \__fp_tuple_|_tuple_o:ww on line ...
Defining \__fp_and_return:wNw on line ...
Defining \__fp_ternary:NwwN on line ...
Defining \__fp_ternary_loop_break:w on line ...
diff --git a/l3kernel/testfiles/m3expl001.ptex.tlg b/l3kernel/testfiles/m3expl001.ptex.tlg
index f6fc677..5644bac 100644
--- a/l3kernel/testfiles/m3expl001.ptex.tlg
+++ b/l3kernel/testfiles/m3expl001.ptex.tlg
@@ -3641,6 +3641,7 @@ Defining \__fp_change_func_type_chk:NNN on line ...
Defining \__fp_exp_after_any_f:Nnw on line ...
Defining \__fp_exp_after_any_f:nw on line ...
Defining \__fp_exp_after_stop_f:nw on line ...
+Defining \__fp_exp_after_tuple_o:w on line ...
Defining \__fp_exp_after_tuple_f:nw on line ...
Defining \__fp_exp_after_array_f:w on line ...
Defining \c__fp_leading_shift_int on line ...
@@ -4079,7 +4080,13 @@ Defining \__fp_minmax_break_o:w on line ...
Defining \__fp_not_o:w on line ...
Defining \__fp_tuple_not_o:w on line ...
Defining \__fp_&_o:ww on line ...
+Defining \__fp_&_tuple_o:ww on line ...
+Defining \__fp_tuple_&_o:ww on line ...
+Defining \__fp_tuple_&_tuple_o:ww on line ...
Defining \__fp_|_o:ww on line ...
+Defining \__fp_|_tuple_o:ww on line ...
+Defining \__fp_tuple_|_o:ww on line ...
+Defining \__fp_tuple_|_tuple_o:ww on line ...
Defining \__fp_and_return:wNw on line ...
Defining \__fp_ternary:NwwN on line ...
Defining \__fp_ternary_loop_break:w on line ...
diff --git a/l3kernel/testfiles/m3expl001.tlg b/l3kernel/testfiles/m3expl001.tlg
index cefe3ab..626911d 100644
--- a/l3kernel/testfiles/m3expl001.tlg
+++ b/l3kernel/testfiles/m3expl001.tlg
@@ -3641,6 +3641,7 @@ Defining \__fp_change_func_type_chk:NNN on line ...
Defining \__fp_exp_after_any_f:Nnw on line ...
Defining \__fp_exp_after_any_f:nw on line ...
Defining \__fp_exp_after_stop_f:nw on line ...
+Defining \__fp_exp_after_tuple_o:w on line ...
Defining \__fp_exp_after_tuple_f:nw on line ...
Defining \__fp_exp_after_array_f:w on line ...
Defining \c__fp_leading_shift_int on line ...
@@ -4079,7 +4080,13 @@ Defining \__fp_minmax_break_o:w on line ...
Defining \__fp_not_o:w on line ...
Defining \__fp_tuple_not_o:w on line ...
Defining \__fp_&_o:ww on line ...
+Defining \__fp_&_tuple_o:ww on line ...
+Defining \__fp_tuple_&_o:ww on line ...
+Defining \__fp_tuple_&_tuple_o:ww on line ...
Defining \__fp_|_o:ww on line ...
+Defining \__fp_|_tuple_o:ww on line ...
+Defining \__fp_tuple_|_o:ww on line ...
+Defining \__fp_tuple_|_tuple_o:ww on line ...
Defining \__fp_and_return:wNw on line ...
Defining \__fp_ternary:NwwN on line ...
Defining \__fp_ternary_loop_break:w on line ...
diff --git a/l3kernel/testfiles/m3expl001.uptex.tlg b/l3kernel/testfiles/m3expl001.uptex.tlg
index 1599de4..76dab5c 100644
--- a/l3kernel/testfiles/m3expl001.uptex.tlg
+++ b/l3kernel/testfiles/m3expl001.uptex.tlg
@@ -3641,6 +3641,7 @@ Defining \__fp_change_func_type_chk:NNN on line ...
Defining \__fp_exp_after_any_f:Nnw on line ...
Defining \__fp_exp_after_any_f:nw on line ...
Defining \__fp_exp_after_stop_f:nw on line ...
+Defining \__fp_exp_after_tuple_o:w on line ...
Defining \__fp_exp_after_tuple_f:nw on line ...
Defining \__fp_exp_after_array_f:w on line ...
Defining \c__fp_leading_shift_int on line ...
@@ -4079,7 +4080,13 @@ Defining \__fp_minmax_break_o:w on line ...
Defining \__fp_not_o:w on line ...
Defining \__fp_tuple_not_o:w on line ...
Defining \__fp_&_o:ww on line ...
+Defining \__fp_&_tuple_o:ww on line ...
+Defining \__fp_tuple_&_o:ww on line ...
+Defining \__fp_tuple_&_tuple_o:ww on line ...
Defining \__fp_|_o:ww on line ...
+Defining \__fp_|_tuple_o:ww on line ...
+Defining \__fp_tuple_|_o:ww on line ...
+Defining \__fp_tuple_|_tuple_o:ww on line ...
Defining \__fp_and_return:wNw on line ...
Defining \__fp_ternary:NwwN on line ...
Defining \__fp_ternary_loop_break:w on line ...
diff --git a/l3kernel/testfiles/m3expl001.xetex.tlg b/l3kernel/testfiles/m3expl001.xetex.tlg
index 06e222c..0d51b71 100644
--- a/l3kernel/testfiles/m3expl001.xetex.tlg
+++ b/l3kernel/testfiles/m3expl001.xetex.tlg
@@ -3651,6 +3651,7 @@ Defining \__fp_change_func_type_chk:NNN on line ...
Defining \__fp_exp_after_any_f:Nnw on line ...
Defining \__fp_exp_after_any_f:nw on line ...
Defining \__fp_exp_after_stop_f:nw on line ...
+Defining \__fp_exp_after_tuple_o:w on line ...
Defining \__fp_exp_after_tuple_f:nw on line ...
Defining \__fp_exp_after_array_f:w on line ...
Defining \c__fp_leading_shift_int on line ...
@@ -4089,7 +4090,13 @@ Defining \__fp_minmax_break_o:w on line ...
Defining \__fp_not_o:w on line ...
Defining \__fp_tuple_not_o:w on line ...
Defining \__fp_&_o:ww on line ...
+Defining \__fp_&_tuple_o:ww on line ...
+Defining \__fp_tuple_&_o:ww on line ...
+Defining \__fp_tuple_&_tuple_o:ww on line ...
Defining \__fp_|_o:ww on line ...
+Defining \__fp_|_tuple_o:ww on line ...
+Defining \__fp_tuple_|_o:ww on line ...
+Defining \__fp_tuple_|_tuple_o:ww on line ...
Defining \__fp_and_return:wNw on line ...
Defining \__fp_ternary:NwwN on line ...
Defining \__fp_ternary_loop_break:w on line ...
diff --git a/l3kernel/testfiles/m3expl003.luatex.tlg b/l3kernel/testfiles/m3expl003.luatex.tlg
index 3634264..fe6a3b1 100644
--- a/l3kernel/testfiles/m3expl003.luatex.tlg
+++ b/l3kernel/testfiles/m3expl003.luatex.tlg
@@ -3653,6 +3653,7 @@ Defining \__fp_change_func_type_chk:NNN on line ...
Defining \__fp_exp_after_any_f:Nnw on line ...
Defining \__fp_exp_after_any_f:nw on line ...
Defining \__fp_exp_after_stop_f:nw on line ...
+Defining \__fp_exp_after_tuple_o:w on line ...
Defining \__fp_exp_after_tuple_f:nw on line ...
Defining \__fp_exp_after_array_f:w on line ...
Defining \c__fp_leading_shift_int on line ...
@@ -4091,7 +4092,13 @@ Defining \__fp_minmax_break_o:w on line ...
Defining \__fp_not_o:w on line ...
Defining \__fp_tuple_not_o:w on line ...
Defining \__fp_&_o:ww on line ...
+Defining \__fp_&_tuple_o:ww on line ...
+Defining \__fp_tuple_&_o:ww on line ...
+Defining \__fp_tuple_&_tuple_o:ww on line ...
Defining \__fp_|_o:ww on line ...
+Defining \__fp_|_tuple_o:ww on line ...
+Defining \__fp_tuple_|_o:ww on line ...
+Defining \__fp_tuple_|_tuple_o:ww on line ...
Defining \__fp_and_return:wNw on line ...
Defining \__fp_ternary:NwwN on line ...
Defining \__fp_ternary_loop_break:w on line ...
diff --git a/l3kernel/testfiles/m3expl003.ptex.tlg b/l3kernel/testfiles/m3expl003.ptex.tlg
index f6fc677..5644bac 100644
--- a/l3kernel/testfiles/m3expl003.ptex.tlg
+++ b/l3kernel/testfiles/m3expl003.ptex.tlg
@@ -3641,6 +3641,7 @@ Defining \__fp_change_func_type_chk:NNN on line ...
Defining \__fp_exp_after_any_f:Nnw on line ...
Defining \__fp_exp_after_any_f:nw on line ...
Defining \__fp_exp_after_stop_f:nw on line ...
+Defining \__fp_exp_after_tuple_o:w on line ...
Defining \__fp_exp_after_tuple_f:nw on line ...
Defining \__fp_exp_after_array_f:w on line ...
Defining \c__fp_leading_shift_int on line ...
@@ -4079,7 +4080,13 @@ Defining \__fp_minmax_break_o:w on line ...
Defining \__fp_not_o:w on line ...
Defining \__fp_tuple_not_o:w on line ...
Defining \__fp_&_o:ww on line ...
+Defining \__fp_&_tuple_o:ww on line ...
+Defining \__fp_tuple_&_o:ww on line ...
+Defining \__fp_tuple_&_tuple_o:ww on line ...
Defining \__fp_|_o:ww on line ...
+Defining \__fp_|_tuple_o:ww on line ...
+Defining \__fp_tuple_|_o:ww on line ...
+Defining \__fp_tuple_|_tuple_o:ww on line ...
Defining \__fp_and_return:wNw on line ...
Defining \__fp_ternary:NwwN on line ...
Defining \__fp_ternary_loop_break:w on line ...
diff --git a/l3kernel/testfiles/m3expl003.tlg b/l3kernel/testfiles/m3expl003.tlg
index cefe3ab..626911d 100644
--- a/l3kernel/testfiles/m3expl003.tlg
+++ b/l3kernel/testfiles/m3expl003.tlg
@@ -3641,6 +3641,7 @@ Defining \__fp_change_func_type_chk:NNN on line ...
Defining \__fp_exp_after_any_f:Nnw on line ...
Defining \__fp_exp_after_any_f:nw on line ...
Defining \__fp_exp_after_stop_f:nw on line ...
+Defining \__fp_exp_after_tuple_o:w on line ...
Defining \__fp_exp_after_tuple_f:nw on line ...
Defining \__fp_exp_after_array_f:w on line ...
Defining \c__fp_leading_shift_int on line ...
@@ -4079,7 +4080,13 @@ Defining \__fp_minmax_break_o:w on line ...
Defining \__fp_not_o:w on line ...
Defining \__fp_tuple_not_o:w on line ...
Defining \__fp_&_o:ww on line ...
+Defining \__fp_&_tuple_o:ww on line ...
+Defining \__fp_tuple_&_o:ww on line ...
+Defining \__fp_tuple_&_tuple_o:ww on line ...
Defining \__fp_|_o:ww on line ...
+Defining \__fp_|_tuple_o:ww on line ...
+Defining \__fp_tuple_|_o:ww on line ...
+Defining \__fp_tuple_|_tuple_o:ww on line ...
Defining \__fp_and_return:wNw on line ...
Defining \__fp_ternary:NwwN on line ...
Defining \__fp_ternary_loop_break:w on line ...
diff --git a/l3kernel/testfiles/m3expl003.uptex.tlg b/l3kernel/testfiles/m3expl003.uptex.tlg
index 1599de4..76dab5c 100644
--- a/l3kernel/testfiles/m3expl003.uptex.tlg
+++ b/l3kernel/testfiles/m3expl003.uptex.tlg
@@ -3641,6 +3641,7 @@ Defining \__fp_change_func_type_chk:NNN on line ...
Defining \__fp_exp_after_any_f:Nnw on line ...
Defining \__fp_exp_after_any_f:nw on line ...
Defining \__fp_exp_after_stop_f:nw on line ...
+Defining \__fp_exp_after_tuple_o:w on line ...
Defining \__fp_exp_after_tuple_f:nw on line ...
Defining \__fp_exp_after_array_f:w on line ...
Defining \c__fp_leading_shift_int on line ...
@@ -4079,7 +4080,13 @@ Defining \__fp_minmax_break_o:w on line ...
Defining \__fp_not_o:w on line ...
Defining \__fp_tuple_not_o:w on line ...
Defining \__fp_&_o:ww on line ...
+Defining \__fp_&_tuple_o:ww on line ...
+Defining \__fp_tuple_&_o:ww on line ...
+Defining \__fp_tuple_&_tuple_o:ww on line ...
Defining \__fp_|_o:ww on line ...
+Defining \__fp_|_tuple_o:ww on line ...
+Defining \__fp_tuple_|_o:ww on line ...
+Defining \__fp_tuple_|_tuple_o:ww on line ...
Defining \__fp_and_return:wNw on line ...
Defining \__fp_ternary:NwwN on line ...
Defining \__fp_ternary_loop_break:w on line ...
diff --git a/l3kernel/testfiles/m3expl003.xetex.tlg b/l3kernel/testfiles/m3expl003.xetex.tlg
index 06e222c..0d51b71 100644
--- a/l3kernel/testfiles/m3expl003.xetex.tlg
+++ b/l3kernel/testfiles/m3expl003.xetex.tlg
@@ -3651,6 +3651,7 @@ Defining \__fp_change_func_type_chk:NNN on line ...
Defining \__fp_exp_after_any_f:Nnw on line ...
Defining \__fp_exp_after_any_f:nw on line ...
Defining \__fp_exp_after_stop_f:nw on line ...
+Defining \__fp_exp_after_tuple_o:w on line ...
Defining \__fp_exp_after_tuple_f:nw on line ...
Defining \__fp_exp_after_array_f:w on line ...
Defining \c__fp_leading_shift_int on line ...
@@ -4089,7 +4090,13 @@ Defining \__fp_minmax_break_o:w on line ...
Defining \__fp_not_o:w on line ...
Defining \__fp_tuple_not_o:w on line ...
Defining \__fp_&_o:ww on line ...
+Defining \__fp_&_tuple_o:ww on line ...
+Defining \__fp_tuple_&_o:ww on line ...
+Defining \__fp_tuple_&_tuple_o:ww on line ...
Defining \__fp_|_o:ww on line ...
+Defining \__fp_|_tuple_o:ww on line ...
+Defining \__fp_tuple_|_o:ww on line ...
+Defining \__fp_tuple_|_tuple_o:ww on line ...
Defining \__fp_and_return:wNw on line ...
Defining \__fp_ternary:NwwN on line ...
Defining \__fp_ternary_loop_break:w on line ...
diff --git a/l3kernel/testfiles/m3fp-logic002.lvt b/l3kernel/testfiles/m3fp-logic002.lvt
index 85c979f..6f598c7 100644
--- a/l3kernel/testfiles/m3fp-logic002.lvt
+++ b/l3kernel/testfiles/m3fp-logic002.lvt
@@ -66,6 +66,14 @@
\fp_to_tl:n { true ? false - true : 1 } \NEWLINE
\fp_to_tl:n { false & true | true } \NEWLINE
\fp_to_tl:n { true | true & false ? 2 : 3 } \NEWLINE
+ \fp_to_tl:n { (1,2) & 7 } \NEWLINE
+ \fp_to_tl:n { 0 & (7,8) } \NEWLINE
+ \fp_to_tl:n { 1 & (7,8) } \NEWLINE
+ \fp_to_tl:n { (1,2) & (7,8) } \NEWLINE
+ \fp_to_tl:n { (1,2) | 7 } \NEWLINE
+ \fp_to_tl:n { 0 | (7,8) } \NEWLINE
+ \fp_to_tl:n { 1 | (7,8) } \NEWLINE
+ \fp_to_tl:n { (1,2) | (7,8) } \NEWLINE
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
diff --git a/l3kernel/testfiles/m3fp-logic002.tlg b/l3kernel/testfiles/m3fp-logic002.tlg
index fe03493..5fd391f 100644
--- a/l3kernel/testfiles/m3fp-logic002.tlg
+++ b/l3kernel/testfiles/m3fp-logic002.tlg
@@ -99,6 +99,14 @@ TEST 7: Booleans true and false
-1
1
2
+7
+0
+(7, 8)
+(7, 8)
+(1, 2)
+(7, 8)
+1
+(1, 2)
============================================================
============================================================
TEST 8: Maximum and minimum
More information about the latex3-commits
mailing list