[latex3-commits] [git/LaTeX3-latex3-latex3] l3bitset-2: rewrite bitset_item to take a name (77a51571f)
Ulrike Fischer
fischer at troubleshooting-tex.de
Tue Dec 29 16:06:09 CET 2020
Repository : https://github.com/latex3/latex3
On branch : l3bitset-2
Link : https://github.com/latex3/latex3/commit/77a51571f6f40238e7b42683e4ef7ec1c628538e
>---------------------------------------------------------------
commit 77a51571f6f40238e7b42683e4ef7ec1c628538e
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date: Tue Dec 29 16:06:09 2020 +0100
rewrite bitset_item to take a name
>---------------------------------------------------------------
77a51571f6f40238e7b42683e4ef7ec1c628538e
l3experimental/l3bitset/l3bitset.dtx | 32 ++++++++++++++++++++------------
1 file changed, 20 insertions(+), 12 deletions(-)
diff --git a/l3experimental/l3bitset/l3bitset.dtx b/l3experimental/l3bitset/l3bitset.dtx
index c04f3dc05..fb24ef4b2 100644
--- a/l3experimental/l3bitset/l3bitset.dtx
+++ b/l3experimental/l3bitset/l3bitset.dtx
@@ -150,7 +150,7 @@
%
% \section{Setting and unsetting bits}
%
-% \begin{function}[added = 2020-12-13]
+% \begin{function}[added = 2020-12-13, updated=2020-12-29]
% { \bitset_set_true:Nn, \bitset_set_true:cn, \bitset_gset_true:Nn, \bitset_gset_true:cn }
% \begin{syntax}
% \cs{bitset_set_true:Nn} \meta{bitset var} \Arg{position}\\
@@ -164,7 +164,7 @@
% If needed the length of the bit vector is enlarged.
% \end{function}
%
-% \begin{function}[added = 2020-12-13]
+% \begin{function}[added = 2020-12-13,updated=2020-12-29]
% { \bitset_set_false:Nn, \bitset_set_false:cn, \bitset_gset_false:Nn, \bitset_set_false:cn }
% \begin{syntax}
% \cs{bitset_set_false:Nn} \meta{bitset var} \Arg{position}\\
@@ -193,13 +193,14 @@
%
% \section{Using bitsets}
%
-% \begin{function}[EXP,added = 2020-12-14]
+% \begin{function}[EXP,added = 2020-12-14, updated=2020-12-29]
% { \bitset_item:Nn, \bitset_item:cn }
% \begin{syntax}
-% \cs{bitset_item:Nn} \meta{bitset var} \Arg{integer expression}
+% \cs{bitset_item:Nn} \meta{bitset var} \Arg{position}
% \end{syntax}
-% Evaluates the \meta{integer expression} and output \texttt{1} if the bit with
-% this index number is set and \texttt{0} otherwise.
+% \cs{bitset_item:Nn} outputs \texttt{1} if the bit with
+% the index number represented by \Arg{position} is set and \texttt{0} otherwise.
+% \Arg{position} is a declared name or a positiv, unsigned explicit number.
% \end{function}
%
% \begin{function}[EXP,added = 2020-12-13]
@@ -667,16 +668,23 @@
% {
% \bitset_item:Nn, \bitset_item:cn
% }
+% All bits that have been set at anytime have an entry in the prop,
+% so we can take everything else as 0.
% \begin{macrocode}
\cs_new:Npn \bitset_item:Nn #1 #2
{
- \int_compare:nNnTF { #2 } > { 0 }
- {
- \int_eval:n { \str_item:Nn #1 { 0 - (#2)} + 0 }
- }
+ \prop_if_in:cnTF { g_@@_\cs_to_str:N #1 _key_prop } {#2}
{
- 0
- }
+ \int_eval:n
+ {
+ \str_item:Nn #1
+ { 0 - ( \prop_item:cn { g_@@_\cs_to_str:N #1 _key_prop }{#2} ) }
+ +0
+ }
+ }
+ {
+ 0
+ }
}
\cs_generate_variant:Nn \bitset_item:Nn {cn}
% \end{macrocode}
More information about the latex3-commits
mailing list.