summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/erw-l3/erw-l3.sty
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2018-06-22 21:53:54 +0000
committerKarl Berry <karl@freefriends.org>2018-06-22 21:53:54 +0000
commita3626b9d3e661dc23421da6df62617d17d7ed476 (patch)
treea4c3d1755b25480f02dbbed94a564db61a88253f /Master/texmf-dist/tex/latex/erw-l3/erw-l3.sty
parent418ec8b6398d992717aa65698aba791c08510b1f (diff)
erw-l3 (22jun18)
git-svn-id: svn://tug.org/texlive/trunk@48069 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/erw-l3/erw-l3.sty')
-rw-r--r--Master/texmf-dist/tex/latex/erw-l3/erw-l3.sty321
1 files changed, 227 insertions, 94 deletions
diff --git a/Master/texmf-dist/tex/latex/erw-l3/erw-l3.sty b/Master/texmf-dist/tex/latex/erw-l3/erw-l3.sty
index b341361f8e7..c0e6f9d5160 100644
--- a/Master/texmf-dist/tex/latex/erw-l3/erw-l3.sty
+++ b/Master/texmf-dist/tex/latex/erw-l3/erw-l3.sty
@@ -13,15 +13,15 @@
%%
\ProvidesExplPackage
{erw-l3} % Package name
- {2018/05/23} % Release date
- {0.1.1} % Release version
+ {2018/6/21} % Release date
+ {0.1.3} % Release version
{Utilities built around expl3} % Description
\NeedsTeXFormat{LaTeX2e}
-\RequirePackage{expl3}[2018/02/21]
-\RequirePackage{xparse}[2018/02/21]
+\RequirePackage{expl3}[2018/06/01]
+\RequirePackage{xparse}[2018/02/01]
\RequirePackage{l3keys2e}
\ExplSyntaxOn
-\msg_new:nnn{erw_compose}{generic}{#1}
+\msg_new:nnn{erw}{generic}{#1}
\cs_set:Npn \erw_compose:NnV
#1 % method
#2 % funs
@@ -33,7 +33,10 @@
{
#1{##1}#3
}
- \erw_map:n{#2}
+ \exp_args:Nf\erw_map:n
+ {
+ \tl_reverse:n{#2}
+ }
}
\cs_set:Npn \erw_compose:nV #1 #2
{
@@ -56,16 +59,6 @@
\erw_compose_c:nV{#1}\__erw_compose_tl
\__erw_compose_tl
}
-\tl_new:N \__erw_fold_seq_item_tl
-\cs_set:Npn \erw_fold_seq:NV
- #1 % fun
- #2 % seq
-{
- \seq_get_right:NN #2 \__erw_fold_seq_item_tl
- \erw_fold:NV #1 \__erw_fold_seq_item_tl
- \seq_put_right:No #2 {\__erw_fold_seq_item_tl}
-}
-\cs_generate_variant:Nn \erw_fold_seq:NV {cV}
\cs_set:Npn \erw_compose_seq:nV #1 #2
{
\erw_compose:NnV \erw_fold_seq:NV {#1} #2
@@ -78,11 +71,11 @@
}
\cs_set:Npn \erw_compose_vers:nV #1 #2
{
- \msg_error:nnn{erw_rec}{generic}{erw_compose_vers:nV~to~be~defined}
+ \msg_error:nnn{erw}{generic}{erw_compose_vers:nV~yet-to~be~implemented}
}
\cs_set:Npn \erw_compose_seq_vers:nV #1 #2
{
- \msg_error:nnn{erw_rec}{generic}{erw_compose_seq_vers:nV~to~be~defined}
+ \msg_error:nnn{erw}{generic}{erw_compose_vers:nV~yet-to~be~implemented}
}
\cs_set:Npn \erw_compose_vers:nn #1 #2
{
@@ -93,45 +86,17 @@
{{\erw_numbrd_cs_names_braced:{}}}
{#2}
}
-\tl_new:N \__erw_disambig_tl
-\keys_define:nn { erw }
+\cs_set:Npn \__erw_cs_name:N #1
{
- disambig .tl_set:N = \__erw_disambig_tl,
- disambig .initial:n = \c_empty_tl
+ \exp_last_unbraced:Nf \use_i:nnn {\cs_split_function:N #1}
}
-\cs_set:Npn \__erw_disambig:NN #1 #2 {#1{#2}}
-\cs_generate_variant:Nn \__erw_disambig:NN { Nc }
-\NewDocumentCommand{\disambignewcmd}{ s m m m }
-{
- \IfBooleanTF{#1}
- {\__erw_disambig:Nc{\RenewDocumentCommand}}
- {\__erw_disambig:Nc{\NewDocumentCommand}}
- {\__erw_disambig_tl #2}
- {#3}
- {#4}
-}
-\NewDocumentCommand{\disambignewenv}{ s m m m m }
-{
- \IfBooleanTF{#1}
- {\RenewDocumentEnvironment}
- {\NewDocumentEnvironment}
- {\__erw_disambig_tl #2}
- {#3}
- {#4}
- {#5}
-}
-\NewDocumentCommand{\disambigset}{ m }
+\cs_set:Npn \erw_apply:Nn
+ #1 % fun
+ #2 % tl
{
- \keys_set:nn { erw }
- {
- disambig={#1}
- }
+ #1{#2}
}
-\ProcessKeysPackageOptions{ erw }
-\msg_new:nnn
- {erw_csutil}
- {generic}
- {#1}
+\cs_generate_variant:Nn \erw_apply:Nn {No, Nf, Nx, c}
\cs_set:Npn \erw_cs_set_eq:NN #1 #2
{
\cs_set:Npn #1 ##1{#2{##1}}
@@ -142,6 +107,85 @@
\cs_set:Npn #1 ##1{#2}
}
\cs_generate_variant:Nn \erw_cs_set_inline:Nn {cn}
+\tl_set:Nn \__erw_fold_set_par_tl{\c_novalue_tl}
+\tl_set:Nn \__erw_fold_apply_par_tl{\c_novalue_tl}
+\cs_set:Npn \erw_fold_set_par:n #1
+{
+ \tl_set:Nn \__erw_fold_set_par_tl{#1}
+}
+\cs_set:Npn \erw_fold_apply_par:n #1
+{
+ \tl_set:Nn \__erw_fold_apply_par_tl{#1}
+}
+\cs_set:Npn \erw_fold:NV
+ #1 % fun
+ #2 % var
+{
+ \use:c{tl_set:\__erw_fold_set_par_tl}
+ #2
+ {\use:c{erw_apply:\__erw_fold_apply_par_tl}{#1}{#2}}
+}
+\cs_generate_variant:Nn \erw_fold:NV {cV}
+\tl_new:N \__erw_fold_seq_item_tl
+\cs_set:Npn \erw_fold_seq:NV
+ #1 % fun
+ #2 % seq
+{
+ \seq_get_right:NN #2 \__erw_fold_seq_item_tl
+ \erw_fold:NV #1 \__erw_fold_seq_item_tl
+ \seq_put_right:No #2 {\__erw_fold_seq_item_tl}
+}
+\cs_generate_variant:Nn \erw_fold_seq:NV {cV}
+\cs_set:Npn \erw_identity:n #1{#1}
+\cs_set:Npn\__erw_items_to:nnn #1 #2 #3
+{
+ \int_compare:nNnTF
+ {#1}>{#2}
+ {
+ \exp_args:Nf \tl_head:n{#3}
+ \__erw_items_to:nnn
+ {#1}
+ {\int_eval:n{#2+1}}
+ {\exp_args:Nf \tl_tail:n{#3}}
+ }
+ {
+ \exp_args:Nf \tl_head:n{#3}
+ }
+}
+\cs_set:Npn \erw_items_to:nn #1 #2
+{
+ \__erw_items_to:nnn
+ {#1}
+ {1}
+ {#2}
+}
+\cs_set:Npn \erw_last_item:n #1
+{
+ \exp_args:Nof \tl_item:nn
+ {#1}
+ {
+ \tl_count:n{#1}
+ }
+}
+\cs_set:Npn \erw_repeat:nn #1 #2
+{
+ \int_step_inline:nnnn{1}{1}{#1}{#2}
+}
+\cs_set:Npn \erw_split:nnn #1 #2 #3
+{
+ \tl_head:n{#1}
+ \use:c{exp_args:#3} \tl_map_inline:nn
+ {
+ \tl_tail:n
+ {
+ #1
+ }
+ }{#2##1}
+}
+\cs_set:Npn \erw_split:nn #1 #2
+{
+ \erw_split:nnn{#1}{#2}{Nf}
+}
\cs_set:Npn \erw_map:n #1
{
\__erw_map:nn#1\q_recursion_tail\q_recursion_stop\q_recursion_tail\q_recursion_stop
@@ -154,7 +198,7 @@
\cs_new:Npn \__erw_map:n #1
{
\msg_error:nnn
- {erw_csutil}
+ {erw}
{generic}
{__erw_map:n~not~set}
}
@@ -172,70 +216,101 @@
\erw_cs_set_inline:Nn \__erw_map:n {#1}
\erw_map:n{#2}
}
-\cs_set:Npn \erw_apply:Nn
- #1 % fun
- #2 % tl
+\cs_set:Npn \erw_apply:Nnn #1 #2 #3
{
- #1{#2}
+ #1{#2}{#3}
}
-\cs_generate_variant:Nn \erw_apply:Nn {No, Nf, Nx, c}
-\tl_set:Nn \__erw_fold_set_par_tl{\c_novalue_tl}
-\tl_set:Nn \__erw_fold_apply_par_tl{\c_novalue_tl}
-\cs_set:Npn \erw_fold_set_par:n #1
+\cs_set:Npn \erw_apply:Nnnn #1 #2 #3 #4
{
- \tl_set:Nn \__erw_fold_set_par_tl{#1}
+ #1{#2}{#3}{#4}
}
-\cs_set:Npn \erw_fold_apply_par:n #1
+\cs_set:Npn \erw_apply:Nnnnn #1 #2 #3 #4 #5
{
- \tl_set:Nn \__erw_fold_apply_par_tl{#1}
+ #1{#2}{#3}{#4}{#5}
}
-\cs_set:Npn \erw_fold:NV
- #1 % fun
- #2 % var
+
+\cs_set:Npn \__erw_map_thread_at:Nnn #1 #2 #3
{
- \use:c{tl_set:\__erw_fold_set_par_tl}
- #2
- {\use:c{erw_apply:\__erw_fold_apply_par_tl}{#1}{#2}}
+ \erw_apply:Nn #1
+ {\exp_args:Nf\tl_item:nn {#3} {#2} }
}
-\cs_generate_variant:Nn \erw_fold:NV {cV}
-\disambignewcmd{numbrdcsnew}{ s m }
+\cs_set:Npn \__erw_map_thread_at:Nnnn #1 #2 #3 #4
+{
+ \erw_apply:Nnn #1
+ {\exp_args:Nf\tl_item:nn {#3} {#2} }
+ {\exp_args:Nf\tl_item:nn {#4} {#2} }
+}
+\cs_set:Npn \__erw_map_thread_at:Nnnnn #1 #2 #3 #4 #5
+{
+ \erw_apply:Nnnn #1
+ {\exp_args:Nf\tl_item:nn {#3} {#2} }
+ {\exp_args:Nf\tl_item:nn {#4} {#2} }
+ {\exp_args:Nf\tl_item:nn {#5} {#2} }
+}
+\cs_set:Npn \__erw_map_thread_at:Nnnnnn #1 #2 #3 #4 #5 #6
+{
+ \erw_apply:Nnnnn #1
+ {\exp_args:Nf\tl_item:nn {#3} {#2} }
+ {\exp_args:Nf\tl_item:nn {#4} {#2} }
+ {\exp_args:Nf\tl_item:nn {#5} {#2} }
+ {\exp_args:Nf\tl_item:nn {#6} {#2} }
+}
+\cs_set:Npn \erw_map_thread_at:Nnn #1 #2 #3
{
-\IfBooleanTF{#1}
-{}
-{ \erw_numbrd_cs_reset:{}}
-\tl_map_function:nN {#2}\erw_numbrd_cs_new:n
+ \exp_args:Nf\int_case:nnTF
+ {
+ \tl_count:n{#3}
+ }
+ {
+ {1}{ \__erw_map_thread_at:Nnn #1{#2}#3 }
+ {2}{ \__erw_map_thread_at:Nnnn #1{#2}#3 }
+ {3}{ \__erw_map_thread_at:Nnnnn #1{#2}#3 }
+ {4}{ \__erw_map_thread_at:Nnnnnn #1{#2}#3 }
+ }
+ {
+ % Do nothing
+ }
+ {
+ \msg_error:nnn{erw}
+ {generic}
+ {erw_map_thread_at:~count~of~#3~not~withing~1~to~4}
+ }
}
-\disambignewcmd{numbrdcs}{ m m }
+
+\cs_set:Npn \erw_map_thread:Nn #1 #2
{
-\erw_numbrd_cs:nn{#1}{#2}
+ % TODO check that #2 is a matrix
+ \int_step_inline:nn
+ {
+ \exp_args:Nf \tl_count:n{ \tl_head:n{#2} }
+ }
+ {
+ \erw_map_thread_at:Nnn #1 {##1} {#2}
+ }
}
-\msg_new:nnn
- {erw_numbrdcs}
- {generic}
- {#1}
\int_new:N \__erw_numbrd_cs_int
\cs_set:Npn \erw_numbrd_cs_name:n #1{__erw_numbrd_cs_\int_to_alph:n{#1}:n}
\cs_set:Npn \erw_numbrd_cs_name_braced:n #1{{\erw_numbrd_cs_name:n{#1}}}
\tl_set:Nn \__erw_numbrd_cs_name_tl {\erw_numbrd_cs_name:n{\__erw_numbrd_cs_int}}
\cs_set:Npn \erw_numbrd_cs:nn #1 #2
{
-\erw_apply:cn{__erw_numbrd_cs_\int_to_alph:n{#1}:n}{#2}
+ \erw_apply:cn{__erw_numbrd_cs_\int_to_alph:n{#1}:n}{#2}
}
\cs_new_protected:Npn \erw_numbrd_cs_reset:
{
-\int_zero:N \__erw_numbrd_cs_int
-\tl_set:Nn \__erw_numbrd_cs_ext_tl{}
+ \int_zero:N \__erw_numbrd_cs_int
+ \tl_set:Nn \__erw_numbrd_cs_ext_tl{}
}
\cs_new_protected:Npn \erw_numbrd_cs_new:n #1
{
-\int_incr:N \__erw_numbrd_cs_int
-\erw_cs_set_inline:cn{\__erw_numbrd_cs_name_tl}
-{
-\token_if_cs:NTF
-{#1}
-{#1{##1}}
-{#1}
-}
+ \int_incr:N \__erw_numbrd_cs_int
+ \erw_cs_set_inline:cn{\__erw_numbrd_cs_name_tl}
+ {
+ \token_if_cs:NTF
+ {#1}
+ {#1{##1}}
+ {#1}
+ }
}
\cs_new:Npn \erw_numbrd_cs_names:nnn #1 #2 #3
{
@@ -250,6 +325,64 @@
{
\erw_numbrd_cs_names_braced:nnn{1}{1}{\__erw_numbrd_cs_int}
}
+\cs_set:Npn \__erw_disambig:NN #1 #2 {#1{#2}}
+\cs_generate_variant:Nn \__erw_disambig:NN { Nc }
+\NewDocumentCommand{\disambignewcmd}{ s m m m }
+{
+ \msg_error:nnn{erw}{generic}{disambignewcmd~undefined}
+}
+\NewDocumentCommand{\disambignewenv}{ s m m m m }
+{
+ \msg_error:nnn{erw}{generic}{disambignewenv~undefined}
+}
+\keys_define:nn { erw }
+{
+ disambig .code:n =
+ {
+ \RenewDocumentCommand{\disambignewcmd}{ s m m m }
+ {
+ \IfBooleanTF{##1}
+ {\__erw_disambig:Nc{\RenewDocumentCommand}}
+ {\__erw_disambig:Nc{\NewDocumentCommand}}
+ {#1 \__erw_cs_name:N ##2}
+ {##3}
+ {##4}
+ }
+ \RenewDocumentCommand{\disambignewenv}{ s m m m m }
+ {
+ \IfBooleanTF{##1}
+ {\RenewDocumentEnvironment}
+ {\NewDocumentEnvironment}
+ {#1##2}
+ {##3}
+ {##4}
+ {##5}
+ }
+ },
+ disambig .initial:n = \c_empty_tl
+}
+\NewDocumentCommand{\disambigset}{ m }
+{
+ \keys_set:nn { erw }
+ {
+ disambig={#1}
+ }
+}
+\NewDocumentCommand{\disambigunset}{}
+{
+ \disambigset{\c_empty_tl}
+}
+\NewDocumentCommand{\numbrdcsnew}{ s m }
+{
+ \IfBooleanTF{#1}
+ {}
+ { \erw_numbrd_cs_reset:{}}
+ \tl_map_function:nN {#2}\erw_numbrd_cs_new:n
+}
+\NewDocumentCommand{\numbrdcs}{ m m }
+{
+ \erw_numbrd_cs:nn{#1}{#2}
+}
\ExplSyntaxOff
%%
%% Copyright (C) 2018 by Erwann Rogard