diff options
author | Karl Berry <karl@freefriends.org> | 2023-11-19 21:30:32 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2023-11-19 21:30:32 +0000 |
commit | 3493a6a6cd024636ccafd48a44bf008efb0f15cf (patch) | |
tree | 4858a290f6d248bbb17ba0870974aa906ea70117 /Master | |
parent | 55dbc600d52f7b7abc2bc5bcd14e4294606367fe (diff) |
starray (19nov23)
git-svn-id: svn://tug.org/texlive/trunk@68907 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rw-r--r-- | Master/texmf-dist/doc/latex/starray/README.md | 5 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/starray/starray.pdf | bin | 266418 -> 268851 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/starray/starray.tex | 29 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/starray/starray.sty | 126 |
4 files changed, 152 insertions, 8 deletions
diff --git a/Master/texmf-dist/doc/latex/starray/README.md b/Master/texmf-dist/doc/latex/starray/README.md index e00db9e4a15..5079dcbc3af 100644 --- a/Master/texmf-dist/doc/latex/starray/README.md +++ b/Master/texmf-dist/doc/latex/starray/README.md @@ -73,7 +73,10 @@ The Current Maintainer of this work is Alceu Frigeri ## Changelog -* Version 1.3 (this) +* Version 1.4 (this) + - added a few functions _set_iter_from_hash:nn and _iterate_over:n. + +* Version 1.3 - Fixed issue #4, where (in some instances) _set_from_keyval could render a quark loop. * Version 1.2 diff --git a/Master/texmf-dist/doc/latex/starray/starray.pdf b/Master/texmf-dist/doc/latex/starray/starray.pdf Binary files differindex 9523653f0a7..b030731578b 100644 --- a/Master/texmf-dist/doc/latex/starray/starray.pdf +++ b/Master/texmf-dist/doc/latex/starray/starray.pdf diff --git a/Master/texmf-dist/doc/latex/starray/starray.tex b/Master/texmf-dist/doc/latex/starray/starray.tex index 5837d2308fd..615d8fe92aa 100644 --- a/Master/texmf-dist/doc/latex/starray/starray.tex +++ b/Master/texmf-dist/doc/latex/starray/starray.tex @@ -15,7 +15,7 @@ %% %% The Current Maintainer of this work is Alceu Frigeri %% -%% This is version 1.3 (2023/06/04) +%% This is version 1.4 (2023/11/18) %% %% The list of files that compose this work can be found in the README.md file at %% https://ctan.org/pkg/starray @@ -450,6 +450,18 @@ Before the reset \tsobj[marg]{st-root.subY.subYYY} was equivalent to \tsobj[marg +\begin{codedescribe}[code,new=2023/11/04]{\starray_set_iter_from_hash:nn,\starray_set_iter_from_hash:nnTF} +\begin{codesyntax}% +\tsmacro{\starray_set_iter_from_hash:nn}{starray-ref,hash} +\tsmacro{\starray_set_iter_from_hash:nnTF}{starray-ref,hash,if-true,if-false} +\end{codesyntax} +\end{codedescribe} +\tsmacro{\starray_set_iter_from_hash:nn}{starray-ref,hash} will set iter based on the \tsobj[meta]{hash} used when instantiating a term (see \ref{pack:instantiate} ). +\begin{tsremark} +A warning is raised (see \ref{pack:options}) in case of a \tsobj[marg]{starray-ref} syntax error or invalid \tsobj[meta]{hash}. The branching version doesn't raise any warning. +\end{tsremark} + + \begin{codedescribe}{\starray_get_iter:n,\starray_get_iter:nN,\starray_get_iter:nNTF} \begin{codesyntax}% \tsmacro{\starray_get_iter:n}{starray-ref} @@ -495,6 +507,21 @@ A warning is raised (see \ref{pack:options}) in case of a \tsobj[marg]{starray-r This can be used after any command which 'parses a term', for instance \tsobj{\starray_term_syntax:n}, see section \ref{conditionals:terms}, but it only makes sense (and returns a reliable/meaningful result) IF the last parser operation was successfully executed. \end{tsremark} +\begin{codedescribe}[code,new=2023/11/04]{\starray_iterate_over:nn,\starray_iterate_over:nnTF} +\begin{codesyntax}% +\tsmacro{\starray_iterate_over:nn}{starray-ref,code} +\tsmacro{\starray_iterate_over:nnTF}{starray-ref,code,if-true,if-false} +\end{codesyntax} +\tsobj{\starray_iterate_over:nn} will reset the \tsobj[marg]{starray-ref} iterator, and then execute \tsobj[marg]{code} for each valid value of \tsobj{iter}. At the loop's end, the \tsobj[marg]{starray-ref} iterator will point to the last element of it. The \tsobj[marg]{if-true} is executed, at the loop's end if there is no syntax error. Similarly \tsobj[marg]{if-false} is only execute if a syntax error is detected. +\end{codedescribe} +\begin{tsremark} +\tsobj{\starray_iterate_over:nn} Creates a local group, so that one can recurse over sub-structures. Be aware, then, that \tsobj[marg]{code} is executed in said local group. +\end{tsremark} +\begin{tsremark} +A warning is raised (see \ref{pack:options}) in case of a \tsobj[marg]{starray-ref} syntax error. The branching version doesn't raise any warning. +\end{tsremark} + + \section{Changing and recovering starray properties}\label{pack:get/set} diff --git a/Master/texmf-dist/tex/latex/starray/starray.sty b/Master/texmf-dist/tex/latex/starray/starray.sty index 0bfe015ab24..fbbb668458f 100644 --- a/Master/texmf-dist/tex/latex/starray/starray.sty +++ b/Master/texmf-dist/tex/latex/starray/starray.sty @@ -12,7 +12,7 @@ %% %% The Current Maintainer of this work is Alceu Frigeri %% -%% This is version 1.3 (2023/06/04) +%% This is version 1.4 (2023/11/18) %% %% The list of files that compose this work can be found in the README.md file at %% https://ctan.org/pkg/starray @@ -24,8 +24,8 @@ \ProvidesExplPackage {starray} - {2023/06/04} - {1.3} + {2023/11/18} + {1.4} {A structured array/hash of properties} %%%%%%% @@ -38,8 +38,8 @@ { name .code:n = starray , prefix .code:n = starray , - date .code:n = 2023/06/04, - version .code:n = 1.3 , + date .code:n = 2023/11/18, + version .code:n = 1.4 , description .code:n = A~structured~array/hash~of~properties } \cs_if_exist:NF \__codedesc_pkg_info:nn @@ -145,6 +145,7 @@ \cs_generate_variant:Nn \seq_gput_right:Nn {ce} \cs_generate_variant:Nn \int_to_Alph:n {e} +\cs_generate_variant:Nn \int_gset:Nn {Ne} \cs_generate_variant:Nn \prop_put:Nnn {Nee , cee} \cs_generate_variant:Nn \prop_gput:Nnn {Nee , cee} @@ -1088,6 +1089,63 @@ %%%% \starray_set_iter %%%% %%%%%%%%%%%%%%% +\prg_new_protected_conditional:Npnn \__starray_set_iter_from_hash:nn #1#2 {T , F, TF} + { + \prop_get:cnN {\l__starray_prefix_tl #1 _base_prop} {iter_hash} \l_tmpa_prop + \prop_get:NnNTF \l_tmpa_prop {#2} \l_tmpa_tl + { + \int_gset:Nn + { \prop_item:cn {\l__starray_prefix_tl #1 _base_prop} {iter} } + { \l_tmpa_tl } + \prg_return_true: + } + { + \prg_return_false: + } + } + + +\cs_new_protected:Npn \starray_set_iter_from_hash:nn #1#2 + { + \__starray_parser:nnTF {\c__starray_no_idx_ending_bool}{#1} + { + \__starray_set_iter_from_hash:nnTF {\l__starray_parsed_ref_tl}{#2} + { + \__starray_set_sub_iter:nnn {}{\l__starray_parsed_ref_tl}{} + } + { + \msg_warning:nnnn {starray} {reference / iter} {iterhash:1} {#1}{#2} + } + } + { + \__starray_msg_dispatch: + \msg_warning:nnnn {starray} {syntax / iter} {iter:1} {#1} + } % returns nothing by default + } + +\prg_new_protected_conditional:Npnn \starray_set_iter_from_hash:nn #1#2 {T, F, TF} + { + \bool_set_true:N \l__starray_rtn_bool + + \__starray_parser:nnTF {\c__starray_no_idx_ending_bool}{#1} + { + \__starray_set_iter_from_hash:nnTF {\l__starray_parsed_ref_tl}{#2} + { + \__starray_set_sub_iter:nnn {}{\l__starray_parsed_ref_tl}{} + \prg_return_true: + } + { + \bool_set_false:N \l__starray_rtn_bool + \prg_return_false: + } + } + { + \bool_set_false:N \l__starray_rtn_bool + \seq_clear:N \l__starray_msg_seq + \prg_return_false: + } % returns nothing by default + } + \cs_new_protected:Npn \starray_set_iter:nn #1#2 { @@ -1226,6 +1284,62 @@ } } + +%%%%%%%%%%%%%%% +%%%% +%%%% \starray_iterate_over +%%%% +%%%%%%%%%%%%%%% +\bool_new:N \l__starray_iterate_bool + +\cs_new_protected:Npn \starray_iterate_over:nn #1#2 + { + + \bool_if_exist:cF {l__starray_iterate_ #1 _bool} + { \bool_new:c {l__starray_iterate_ #1 _bool} } + \starray_reset_iter:nTF {#1} + { + \bool_gset_true:c {l__starray_iterate_ #1 _bool} + \bool_do_while:cn {l__starray_iterate_ #1 _bool} + { + + #2 + + \starray_next_iter:nTF {#1} + { \bool_gset_true:c {l__starray_iterate_ #1 _bool} } + { \bool_gset_false:c {l__starray_iterate_ #1 _bool} } + } + } + { + \bool_set_false:N \l__starray_rtn_bool + \msg_warning:nnnn {starray} {syntax / iter} {iter:6} {#1} + } + + } + +\prg_new_protected_conditional:Npnn \starray_iterate_over:nn #1#2 {T, F, TF} + { + \bool_if_exist:cF {l__starray_iterate_#1_bool}{\bool_new:c {l__starray_iterate_#1_bool}} + \starray_reset_iter:nTF {#1} + { + \bool_gset_true:c {l__starray_iterate_#1_bool} + \bool_do_while:cn {l__starray_iterate_#1_bool} + { + #2 + \starray_next_iter:nF {#1} + %{\bool_gset_true:c {l__starray_iterate_#1_bool}} + {\bool_gset_false:c {l__starray_iterate_#1_bool}} + } + \prg_return_true: + } + { + \seq_clear:N \l__starray_msg_seq + \prg_return_false: + } + } + + + %%%%%%%%%%%%%%% %%%%%%%%%%%%%%% %%%% @@ -1265,7 +1379,7 @@ %%%%%%%%%%%%%%%% %%% -%%% WARNING: This is uses the 'last parsed term'. +%%% WARNING: This uses the 'last parsed term'. %%% %%%%%%%%%%%%%%%% \cs_new:Npn \starray_parsed_get_prop:n #1 |