diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/hobby/pml3array.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/hobby/pml3array.sty | 161 |
1 files changed, 143 insertions, 18 deletions
diff --git a/Master/texmf-dist/tex/latex/hobby/pml3array.sty b/Master/texmf-dist/tex/latex/hobby/pml3array.sty index e704e4c41ab..3aeb1e6849b 100644 --- a/Master/texmf-dist/tex/latex/hobby/pml3array.sty +++ b/Master/texmf-dist/tex/latex/hobby/pml3array.sty @@ -46,11 +46,40 @@ \prop_put:Nnx #1 {top} {\int_eval:n {#2}} } } +\cs_new:Npn \array_gadjust_ends:Nn #1#2 { + \prop_get:NnNTF #1 {base} \l_tmpa_tl + { + \int_compare:nNnTF {\l_tmpa_tl} > {#2} + { + \prop_gput:Nnx #1 {base} {\int_eval:n {#2}} + } + {} + } + { + \prop_gput:Nnx #1 {base} {\int_eval:n {#2}} + } + \prop_get:NnNTF #1 {top} \l_tmpa_tl + { + \int_compare:nNnTF {\l_tmpa_tl} < {#2} + { + \prop_gput:Nnx #1 {top} {\int_eval:n {#2}} + } + {} + } + { + \prop_gput:Nnx #1 {top} {\int_eval:n {#2}} + } +} \cs_new:Npn \array_put:Nnn #1#2#3 { \exp_args:NNx \prop_put:Nnn #1 {\int_eval:n {#2}} {#3} \array_adjust_ends:Nn #1{#2} } \cs_generate_variant:Nn \array_put:Nnn {Nnx} +\cs_new:Npn \array_gput:Nnn #1#2#3 { + \exp_args:NNx \prop_gput:Nnn #1 {\int_eval:n {#2}} {#3} + \array_gadjust_ends:Nn #1{#2} +} +\cs_generate_variant:Nn \array_gput:Nnn {Nnx} \cs_new:Npn \array_get:NnN #1#2#3 { \exp_args:NNx \prop_get:NnN #1 {\int_eval:n {#2}} #3 } @@ -60,9 +89,17 @@ \cs_new:Npn \array_get:NnNTF #1#2#3#4#5 { \exp_args:NNx \prop_get:NnNTF #1 {\int_eval:n {#2}} #3 {#4}{#5} } -\cs_new_eq:NN \array_if_empty:NTF \prop_if_empty:NTF +\prg_new_conditional:Npnn \array_if_empty:N #1 { p, T, F, TF } +{ + \if_meaning:w #1 \c_empty_prop + \prg_return_true: + \else: + \prg_return_false: + \fi: +} \cs_new_eq:NN \array_new:N \prop_new:N \cs_new_eq:NN \array_clear:N \prop_clear:N +\cs_new_eq:NN \array_gclear:N \prop_gclear:N \cs_new:Npn \array_map_function:NN #1#2 { \array_if_empty:NTF #1 {} { @@ -76,9 +113,9 @@ }{ \int_set:Nn \l_array_top_int {0} } - \prg_stepwise_inline:nnnn {\l_array_base_int} {1} {\l_array_top_int} { + \int_step_inline:nnnn {\l_array_base_int} {1} {\l_array_top_int} { \array_get:NnN #1 {##1} \l_array_tmp_tl - \exp_args:Nno #2 {##1} \l_array_tmp_tl + \exp_args:NnV #2 {##1} \l_array_tmp_tl } } {} } @@ -97,7 +134,7 @@ }{ \int_set:Nn \l_array_top_int {0} } - \prg_stepwise_inline:nnnn {\l_array_top_int} {-1} {\l_array_base_int} { + \int_step_inline:nnnn {\l_array_top_int} {-1} {\l_array_base_int} { \array_get:NnN #1 {##1} \l_array_tmp_tl \exp_args:Nno #2 {##1} \l_array_tmp_tl } @@ -107,25 +144,29 @@ \cs_generate_variant:Nn \array_reverse_map_function:NN { c , cc } \cs_new_protected:Npn \array_map_inline:Nn #1#2 { - \int_gincr:N \g_prg_map_int - \cs_gset:cpn { array_map_inline_ \int_use:N \g_prg_map_int :nn } + \int_gincr:N \g__prg_map_int + \cs_gset:cpn { array_map_inline_ \int_use:N \g__prg_map_int :nn } ##1##2 {#2} \exp_args:NNc \array_map_function:NN #1 - { array_map_inline_ \int_use:N \g_prg_map_int :nn } - \prg_break_point:n { \int_gdecr:N \g_prg_map_int } + { array_map_inline_ \int_use:N \g__prg_map_int :nn } + \__prg_break_point:Nn \array_map_break: { \int_gdecr:N \g__prg_map_int } } \cs_generate_variant:Nn \array_map_inline:Nn { c } \cs_new_protected:Npn \array_reverse_map_inline:Nn #1#2 { - \int_gincr:N \g_prg_map_int - \cs_gset:cpn { array_map_inline_ \int_use:N \g_prg_map_int :nn } + \int_gincr:N \g__prg_map_int + \cs_gset:cpn { array_map_inline_ \int_use:N \g__prg_map_int :nn } ##1##2 {#2} \exp_args:NNc \array_reverse_map_function:NN #1 - { array_map_inline_ \int_use:N \g_prg_map_int :nn } - \prg_break_point:n { \int_gdecr:N \g_prg_map_int } + { array_map_inline_ \int_use:N \g__prg_map_int :nn } + \__prg_break_point:Nn \array_map_break: { \int_gdecr:N \g__prg_map_int } } \cs_generate_variant:Nn \array_reverse_map_inline:Nn { c } -\msg_new:nnn { array } { show } +\cs_new_nopar:Npn \array_map_break: + { \__prg_map_break:Nn \array_map_break: { } } +\cs_new_nopar:Npn \array_map_break:n + { \__prg_map_break:Nn \array_map_break: } +\__msg_kernel_new:nnn { kernel } { show-array } { The~array~\token_to_str:N #1~ \array_if_empty:NTF #1 @@ -136,15 +177,16 @@ { \tl_clear:N \l_array_show_tl \array_map_function:NN #1 \array_show_aux:nn - \__msg_show_variable:Nnx + \__msg_show_variable:Nno #1 { array } - { \l_array_show_tl } + { \l_array_show_tl } } +\cs_generate_variant:Nn \__msg_show_variable:Nnn { Nno } \cs_new_protected:Npn \array_show_aux:nn #1#2 { - \tl_if_eq:NNTF {#2} {\q_no_value} {} + \tl_if_eq:nnTF {#2} {\q_no_value} {} { \tl_put_right:No \l_array_show_tl {\__msg_show_item:nn {#1}{#2}} } @@ -163,6 +205,19 @@ } } \cs_generate_variant:Nn \array_push:Nn {Nx} +\cs_new_protected:Npn \array_gpush:Nn #1#2 +{ + \prop_get:NnNTF #1 {top} \l_array_tmp_tl + { + \int_set:Nn \l_array_tmp_int {\l_array_tmp_tl} + \int_incr:N \l_array_tmp_int + \array_gput:Nnn #1 {\l_array_tmp_int} {#2} + } + { + \array_gput:Nnn #1 {\g_array_base_int} {#2} + } +} +\cs_generate_variant:Nn \array_gpush:Nn {Nx} \cs_new_protected:Npn \array_unshift:Nn #1#2 { \prop_get:NnNTF #1 {base} \l_array_tmp_tl @@ -176,18 +231,43 @@ } } \cs_generate_variant:Nn \array_unshift:Nn {Nx} +\cs_new_protected:Npn \array_gunshift:Nn #1#2 +{ + \prop_get:NnNTF #1 {base} \l_array_tmp_tl + { + \int_set:Nn \l_array_tmp_int {\l_array_tmp_tl} + \int_decr:N \l_array_tmp_int + \array_gput:Nnn #1 {\l_array_tmp_int} {#2} + } + { + \array_gput:Nnn #1 {\g_array_base_int} {#2} + } +} +\cs_generate_variant:Nn \array_gunshift:Nn {Nx} \cs_new_protected:Npn \array_pop:NN #1#2 { \prop_get:NnN #1 {top} \l_array_tmp_tl \array_get:NnN #1 {\l_array_tmp_tl} #2 \array_del:Nn #1 {\l_array_tmp_tl} } +\cs_new_protected:Npn \array_gpop:NN #1#2 +{ + \prop_get:NnN #1 {top} \l_array_tmp_tl + \array_get:NnN #1 {\l_array_tmp_tl} #2 + \array_gdel:Nn #1 {\l_array_tmp_tl} +} \cs_new_protected:Npn \array_shift:NN #1#2 { \prop_get:NnN #1 {base} \l_array_tmp_tl \array_get:NnN #1 {\l_array_tmp_tl} #2 \array_del:Nn #1 {\l_array_tmp_tl} } +\cs_new_protected:Npn \array_gshift:NN #1#2 +{ + \prop_get:NnN #1 {base} \l_array_tmp_tl + \array_get:NnN #1 {\l_array_tmp_tl} #2 + \array_gdel:Nn #1 {\l_array_tmp_tl} +} \cs_new_protected:Npn \array_top:NN #1#2 { \prop_get:NnN #1 {top} \l_array_tmp_tl @@ -208,7 +288,7 @@ } \cs_new_protected:Npn \array_del:Nn #1#2 { - \exp_args:NNx \prop_del:Nn #1 {\int_eval:n {#2}} + \exp_args:NNx \prop_pop:Nn #1 {\int_eval:n {#2}} \int_set:Nn \l_array_tmp_int {0} \array_map_inline:Nn #1 { \tl_if_eq:NNTF {##2} {\q_no_value} {} @@ -237,7 +317,7 @@ }{} \prop_get:NnN #1 {base} \l_array_tmp_tl \int_compare:nNnTF {#2} = {\l_array_tmp_tl} { -p \prop_get:NnN #1 {top} \l_array_tmp_tl + \prop_get:NnN #1 {top} \l_array_tmp_tl \int_set:Nn \l_array_tmp_int {\l_array_tmp_tl} \array_map_inline:Nn #1 { \tl_if_eq:NNTF {##2} {\q_no_value} {} @@ -251,6 +331,51 @@ p \prop_get:NnN #1 {top} \l_array_tmp_tl }{} } } +\cs_new_protected:Npn \array_gdel:Nn #1#2 +{ + \exp_args:NNx \prop_gpop:Nn #1 {\int_eval:n {#2}} + \int_set:Nn \l_array_tmp_int {0} + \array_map_inline:Nn #1 { + \tl_if_eq:NNTF {##2} {\q_no_value} {} + { + \int_incr:N \l_array_tmp_int + } + } + \int_compare:nNnTF {\l_array_tmp_int} = {0} + { + \prop_gclear:N #1 + } + { + \prop_get:NnN #1 {top} \l_array_tmp_tl + \int_compare:nNnTF {#2} = {\l_array_tmp_tl} { + \prop_get:NnN #1 {base} \l_array_tmp_tl + \int_set:Nn \l_array_tmp_int {\l_array_tmp_tl} + \array_map_inline:Nn #1 { + \tl_if_eq:NNTF {##2} {\q_no_value} {} + { + \int_compare:nNnTF {\l_array_tmp_int} < {##1} { + \int_set:Nn \l_array_tmp_int {##1} + }{} + } + } + \prop_gput:Nnx #1 {top} {\int_use:N \l_array_tmp_int} + }{} + \prop_get:NnN #1 {base} \l_array_tmp_tl + \int_compare:nNnTF {#2} = {\l_array_tmp_tl} { + \prop_get:NnN #1 {top} \l_array_tmp_tl + \int_set:Nn \l_array_tmp_int {\l_array_tmp_tl} + \array_map_inline:Nn #1 { + \tl_if_eq:NNTF {##2} {\q_no_value} {} + { + \int_compare:nNnTF {\l_array_tmp_int} > {##1} { + \int_set:Nn \l_array_tmp_int {##1} + }{} + } + } + \prop_gput:Nnx #1 {base} {\int_use:N \l_array_tmp_int} + }{} + } +} \cs_new_protected:Npn \array_length:N #1 { \int_eval:n {\prop_get:Nn #1 {top} - \prop_get:Nn #1 {base}} |