diff options
author | Karl Berry <karl@freefriends.org> | 2009-06-09 23:31:15 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2009-06-09 23:31:15 +0000 |
commit | 215b9a864d5829070bdc66ba736986eb72e5143e (patch) | |
tree | fe0882c81fc4ec945cee4b512f72eaa21ea5f791 /Master/texmf-dist/tex/latex/expl3/l3seq.sty | |
parent | df90ec06321940c2f066b05e12f1b5ab099105da (diff) |
expl3 1407 (9jun09)
git-svn-id: svn://tug.org/texlive/trunk@13686 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/expl3/l3seq.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/expl3/l3seq.sty | 249 |
1 files changed, 134 insertions, 115 deletions
diff --git a/Master/texmf-dist/tex/latex/expl3/l3seq.sty b/Master/texmf-dist/tex/latex/expl3/l3seq.sty index c4ebb497c03..a28d9f64ad7 100644 --- a/Master/texmf-dist/tex/latex/expl3/l3seq.sty +++ b/Master/texmf-dist/tex/latex/expl3/l3seq.sty @@ -15,7 +15,7 @@ %% Do not distribute a modified version of this file. %% %% -%% File: l3seq.dtx Copyright (C) 1990-2006 LaTeX3 project +%% File: l3seq.dtx Copyright (C) 1990-2009 LaTeX3 project %% %% It may be distributed and/or modified under the conditions of the %% LaTeX Project Public License (LPPL), either version 1.3c of this @@ -33,7 +33,7 @@ %% %% The development version of the bundle can be found at %% -%% http://www.latex-project.org/cgi-bin/cvsweb.cgi/ +%% http://www.latex-project.org/svnroot/experimental/trunk/ %% %% for those people who are interested. %% @@ -48,128 +48,147 @@ %% %% ----------------------------------------------------------------------- \RequirePackage{l3names} -\GetIdInfo$Id: l3seq.dtx 621 2007-09-01 20:14:19Z morten $ +\GetIdInfo$Id: l3seq.dtx 1362 2009-05-28 20:19:21Z joseph $ {L3 Experimental sequences and stacks} \ProvidesExplPackage {\filename}{\filedate}{\fileversion}{\filedescription} -\RequirePackage{l3quark} -\RequirePackage{l3tlp} -\RequirePackage{l3expan} -\let_new:NN \seq_elt:w \ERROR -\let_new:NN \seq_elt_end: \ERROR -\def_new:Npn \seq_new:N #1{\tlp_new:Nn #1{}} -\def_new:Npn \seq_new:c {\exp_args:Nc \seq_new:N} -\let_new:NN \seq_clear:N \tlp_clear:N -\let_new:NN \seq_clear:c \tlp_clear:c -\let_new:NN \seq_gclear:N \tlp_gclear:N -\let_new:NN \seq_gclear:c \tlp_gclear:c -\let_new:NN \seq_clear_new:N \tlp_clear_new:N -\let_new:NN \seq_clear_new:c \tlp_clear_new:c -\let_new:NN \seq_gclear_new:N \tlp_gclear_new:N -\let_new:NN \seq_gclear_new:c \tlp_gclear_new:c -\let_new:NN \seq_if_empty_p:N \tlp_if_empty_p:N -\let_new:NN \seq_if_empty:NTF \tlp_if_empty:NTF -\def_new:Npn \seq_if_empty:cTF {\exp_args:Nc\seq_if_empty:NTF} -\let_new:NN \seq_if_empty:NF \tlp_if_empty:NF -\def_new:Npn \seq_if_empty:cF {\exp_args:Nc\seq_if_empty:NF} -\def_new:Npn \seq_if_empty_err:N #1{\if_meaning:NN#1\c_empty_tlp - \tlp_clear:N \l_testa_tlp % catch prefixes - \err_latex_bug:x{Empty~sequence~`\token_to_string:N#1'}\fi:} -\def_new:Npn \seq_get:NN #1{ +\package_check_loaded_expl: +\cs_new:Npn \seq_elt:w {\ERROR} +\cs_new:Npn \seq_elt_end: {\ERROR} +\cs_new_eq:NN \seq_new:N \tl_new:N +\cs_new_eq:NN \seq_new:c \tl_new:c +\cs_new_eq:NN \seq_clear:N \tl_clear:N +\cs_new_eq:NN \seq_clear:c \tl_clear:c +\cs_new_eq:NN \seq_gclear:N \tl_gclear:N +\cs_new_eq:NN \seq_gclear:c \tl_gclear:c +\cs_new_eq:NN \seq_clear_new:N \tl_clear_new:N +\cs_new_eq:NN \seq_clear_new:c \tl_clear_new:c +\cs_new_eq:NN \seq_gclear_new:N \tl_gclear_new:N +\cs_new_eq:NN \seq_gclear_new:c \tl_gclear_new:c +\cs_new_eq:NN \seq_set_eq:NN \cs_set_eq:NN +\cs_new_eq:NN \seq_set_eq:cN \cs_set_eq:cN +\cs_new_eq:NN \seq_set_eq:Nc \cs_set_eq:Nc +\cs_new_eq:NN \seq_set_eq:cc \cs_set_eq:cc +\cs_new_eq:NN \seq_gset_eq:NN \cs_gset_eq:NN +\cs_new_eq:NN \seq_gset_eq:cN \cs_gset_eq:cN +\cs_new_eq:NN \seq_gset_eq:Nc \cs_gset_eq:Nc +\cs_new_eq:NN \seq_gset_eq:cc \cs_gset_eq:cc +\cs_new_nopar:Npn \seq_gconcat:NNN #1#2#3 { + \tl_gset:Nx #1 { \exp_not:V #2 \exp_not:V #3 } +} +\cs_generate_variant:Nn \seq_gconcat:NNN {ccc} +\prg_new_eq_conditional:NNn \seq_if_empty:N \tl_if_empty:N {p,TF,T,F} +\prg_new_eq_conditional:NNn \seq_if_empty:c \tl_if_empty:c {p,TF,T,F} +\cs_new_nopar:Npn \seq_if_empty_err:N #1 { + \if_meaning:w #1 \c_empty_tl + \tl_clear:N \l_testa_tl % catch prefixes + \msg_kernel_bug:x {Empty~sequence~`\token_to_str:N#1'} + \fi: +} +\prg_new_conditional:Nnn \seq_if_in:Nn {TF,T,F} { + \cs_set:Npn \seq_tmp:w ##1 \seq_elt:w #2 \seq_elt_end: ##2##3 \q_stop { + \if_meaning:w \q_no_value ##2 + \prg_return_false: \else: \prg_return_true: \fi: + } + \exp_after:wN \seq_tmp:w #1 \seq_elt:w #2 \seq_elt_end: \q_no_value \q_stop +} +\cs_generate_variant:Nn \seq_if_in:NnTF {cV,co,c,cx} +\cs_generate_variant:Nn \seq_if_in:NnT {cV,co,c,cx} +\cs_generate_variant:Nn \seq_if_in:NnF {cV,co,c,cx} +\cs_new_nopar:Npn \seq_get:NN #1 { \seq_if_empty_err:N #1 - \exp_after:NN\seq_get_aux:w #1\q_stop} -\def_new:Npn \seq_get_aux:w \seq_elt:w #1\seq_elt_end: - #2\q_stop #3{\tlp_set:Nn #3{#1}} -\def_new:Npn \seq_get:cN {\exp_args:Nc \seq_get:NN} -\def_new:Npn \seq_pop_aux:nnNN #1#2#3{ + \exp_after:wN \seq_get_aux:w #1 \q_stop +} +\cs_new:Npn \seq_get_aux:w \seq_elt:w #1 \seq_elt_end: #2 \q_stop #3 { + \tl_set:Nn #3 {#1} +} +\cs_generate_variant:Nn \seq_get:NN {c} +\cs_new:Npn \seq_pop_aux:nnNN #1#2#3 { \seq_if_empty_err:N #3 - \exp_after:NN\seq_pop_aux:w #3\q_stop #1#2#3} -\def_new:Npn \seq_pop_aux:w \seq_elt:w #1\seq_elt_end: - #2\q_stop #3#4#5#6{#3#5{#2}#4#6{#1}} -\def_new:Npn \seq_put_aux:Nnn #1{ - \exp_after:NN\seq_put_aux:w #1\q_stop #1} -\def_new:Npn \seq_put_aux:w #1\q_stop #2#3#4{\tlp_set:Nn #2{#3#1#4}} -\def_new:Npn \seq_put_left:Nn #1#2{ - \seq_put_aux:Nnn #1{\seq_elt:w #2\seq_elt_end:}{}} -\def_new:Npn \seq_put_left:cn {\exp_args:Nc\seq_put_left:Nn} -\def_new:Npn \seq_put_left:No {\exp_args:NNo\seq_put_left:Nn} -\def_new:Npn \seq_put_left:Nx {\exp_args:Nnx\seq_put_left:Nn} -\def_new:Npn \seq_put_right:Nn #1#2{ + \exp_after:wN \seq_pop_aux:w #3 \q_stop #1#2#3 +} +\cs_new:Npn \seq_pop_aux:w + \seq_elt:w #1 \seq_elt_end: #2\q_stop #3#4#5#6 { + #3 #5 {#2} + #4 #6 {#1} +} +\cs_new_eq:NN \seq_show:N \tl_show:N +\cs_new_eq:NN \seq_show:c \tl_show:c +\cs_new_nopar:Npn \seq_display:N #1 { + \iow_term:x { Sequence~\token_to_str:N #1~contains~ + the~elements~(without~outer~braces): } + \toks_clear:N \l_tmpa_toks + \seq_map_inline:Nn #1 { + \toks_if_empty:NF \l_tmpa_toks { + \toks_put_right:Nx \l_tmpa_toks {^^J>~} + } + \toks_put_right:Nx \l_tmpa_toks { + \iow_space: \iow_char:N \{ \exp_not:n {##1} \iow_char:N \} + } + } + \toks_show:N \l_tmpa_toks +} +\cs_generate_variant:Nn \seq_display:N {c} +\cs_new:Npn \seq_put_aux:Nnn #1 { + \exp_after:wN \seq_put_aux:w #1 \q_stop #1 +} +\cs_new:Npn \seq_put_aux:w #1\q_stop #2#3#4 { \tl_set:Nn #2 {#3#1#4} } +\cs_new:Npn \seq_put_left:Nn #1#2 { + \seq_put_aux:Nnn #1 {\seq_elt:w #2\seq_elt_end:} {} +} +\cs_generate_variant:Nn \seq_put_left:Nn {NV,No,Nx,c,cV,co} +\cs_new:Npn \seq_put_right:Nn #1#2{ \seq_put_aux:Nnn #1{}{\seq_elt:w #2\seq_elt_end:}} -\def_new:Npn \seq_put_right:No {\exp_args:NNo\seq_put_right:Nn} -\def_new:Npn \seq_put_right:Nx {\exp_args:NNx\seq_put_right:Nn} -\def_new:Npn \seq_gput_left:Nn { - \pref_global:D - \seq_put_left:Nn} -\def_new:Npn \seq_gput_right:Nn { - \pref_global:D - \seq_put_right:Nn} -\def_new:Npn \seq_gput_right:No {\exp_args:NNo \seq_gput_right:Nn} -\def_new:Npn \seq_gput_right:Nc {\exp_args:NNc \seq_gput_right:Nn} -\def_new:Npn \seq_gput_right:cn {\exp_args:Nc \seq_gput_right:Nn} -\def_new:Npn \seq_gput_right:co {\exp_args:Nco \seq_gput_right:Nn} -\def_new:Npn \seq_gput_right:cc {\exp_args:Ncc \seq_gput_right:Nn} -\def_new:Npn \seq_map_variable_aux:Nnw #1#2\seq_elt:w#3\seq_elt_end:{ - \tlp_set:Nn #1{#3} - \quark_if_nil:NT #1 \seq_map_break:w +\cs_generate_variant:Nn \seq_put_right:Nn {NV,No,Nx,c,cV,co} +\cs_new:Npn \seq_gput_left:Nn { + \pref_global:D + \seq_put_left:Nn +} +\cs_new:Npn \seq_gput_right:Nn { + \pref_global:D + \seq_put_right:Nn +} +\cs_generate_variant:Nn \seq_gput_left:Nn {NV,No,Nx,c,cV,co} +\cs_generate_variant:Nn \seq_gput_right:Nn {NV,No,Nx,c,cV,co} +\cs_generate_variant:Nn \seq_gput_right:Nn {Nc} +\cs_new:Npn \seq_map_variable_aux:Nnw #1#2 \seq_elt:w #3 \seq_elt_end: { + \tl_set:Nx #1{\exp_not:n{#3}} + \quark_if_nil:NT #1 \seq_map_break: #2 \seq_map_variable_aux:Nnw #1{#2} } -\def_new:Npn \seq_map_variable:NNn #1#2#3{ - \tlp_set:Nx #2 {\exp_not:n{\seq_map_variable_aux:Nnw #2{#3}}} - \exp_after:NN #2 #1 \seq_elt:w \q_nil\seq_elt_end: \q_stop -} -\def_new:Npn \seq_map_variable:cNn{\exp_args:Nc\seq_map_variable:Nn} -\let_new:NN \seq_map_break:w \use_none_delimit_by_q_stop:w -\def_new:Npn \seq_map:NN #1#2{ - \def:Npn \seq_elt:w ##1\seq_elt_end: {#2{##1}}#1 - \let:NN \seq_elt:w \ERROR -} -\def_new:Npn \seq_map_inline:Nn #1#2{ - \def:Npn \seq_elt:w ##1\seq_elt_end: {#2}#1 - \let:NN \seq_elt:w \ERROR -} -\def_new:Npn \seq_map_inline:cn{\exp_args:Nc\seq_map_inline:Nn} -\let_new:NN \seq_set_eq:NN \let:NN -\def_new:Npn \seq_set_eq:Nc {\exp_args:NNc \seq_set_eq:NN} -\let_new:NN \seq_gset_eq:NN \glet:NN -\def_new:Npn \seq_gset_eq:cN {\exp_args:Nc \seq_gset_eq:NN} -\def_new:Npn \seq_gset_eq:Nc {\exp_args:NNc \seq_gset_eq:NN} -\def_new:Npn \seq_gset_eq:cc {\exp_args:Ncc \seq_gset_eq:NN} -\def_new:Npn \seq_gconcat:NNN #1#2#3{ - \tlp_gset:Nx #1 {\exp_not:o{#2}\exp_not:o{#3}} -} -\def_new:Npn \seq_gconcat:ccc{\exp_args:Nccc\seq_gconcat:NNN} -\def_new:Npn \seq_if_in:NnTF #1#2{ - \def:Npn\tmp:w - ##1\seq_elt:w #2\seq_elt_end: ##2##3\q_stop{ - \if_meaning:NN\q_no_value##2 - \exp_after:NN\use_arg_ii:nn - \else: - \exp_after:NN\use_arg_i:nn - \fi: - } - \exp_after:NN - \tmp:w #1\seq_elt:w - #2\seq_elt_end: \q_no_value \q_stop} -\def_new:Npn \seq_if_in:coTF {\exp_args:Nco \seq_if_in:NnTF} -\def_new:Npn \seq_if_in:cnTF {\exp_args:Nc \seq_if_in:NnTF} -\def_new:Npn \seq_if_in:cxTF {\exp_args:Ncx \seq_if_in:NnTF} -\def_new:Npn \seq_if_in:NnF #1#2 { \seq_if_in:NnTF #1{#2}\use_noop: } -\def_new:Npn \seq_if_in:cnF {\exp_args:Nc \seq_if_in:NnF} -\let_new:NN \seq_push:Nn \seq_put_left:Nn -\let_new:NN \seq_push:No \seq_put_left:No -\let_new:NN \seq_push:cn \seq_put_left:cn -\def_new:Npn \seq_pop:NN {\seq_pop_aux:nnNN \tlp_set:Nn \tlp_set:Nn} -\def_new:Npn \seq_pop:cN {\exp_args:Nc \seq_pop:NN} -\let_new:NN \seq_gpush:Nn \seq_gput_left:Nn -\def_new:Npn \seq_gpush:No {\exp_args:NNo \seq_gpush:Nn} -\def_new:Npn \seq_gpush:cn {\exp_args:Nc \seq_gpush:Nn} -\def_new:Npn \seq_gpush:NC {\exp_args:NNC \seq_gpush:Nn} -\def_new:Npn \seq_gpop:NN {\seq_pop_aux:nnNN \tlp_gset:Nn \tlp_set:Nn} -\def_new:Npn \seq_gpop:cN {\exp_args:Nc \seq_gpop:NN} -\let_new:NN \seq_top:NN \seq_get:NN -\let_new:NN \seq_top:cN \seq_get:cN +\cs_new:Npn \seq_map_variable:NNn #1#2#3 { + \tl_set:Nx #2 {\exp_not:n{\seq_map_variable_aux:Nnw #2{#3}}} + \exp_after:wN #2 #1 \seq_elt:w \q_nil\seq_elt_end: \q_stop +} +\cs_generate_variant:Nn \seq_map_variable:NNn {c} + +\cs_new_eq:NN \seq_map_break: \use_none_delimit_by_q_stop:w +\cs_new_eq:NN \seq_map_break:n \use_i_delimit_by_q_stop:nw +\cs_new_nopar:Npn \seq_map_function:NN #1#2 { + \cs_set:Npn \seq_elt:w ##1 \seq_elt_end: {#2{##1}} + #1 + \cs_set_eq:NN \seq_elt:w \ERROR +} +\cs_generate_variant:Nn \seq_map_function:NN {c} +\cs_new_nopar:Npn \seq_map_inline:Nn #1#2 { + \cs_set:Npn \seq_elt:w ##1 \seq_elt_end: {#2} + #1 + \cs_set_eq:NN \seq_elt:w \ERROR +} +\cs_generate_variant:Nn \seq_map_inline:Nn {c} +\cs_new_eq:NN \seq_push:Nn \seq_put_left:Nn +\cs_new_eq:NN \seq_push:NV \seq_put_left:NV +\cs_new_eq:NN \seq_push:No \seq_put_left:No +\cs_new_eq:NN \seq_push:cn \seq_put_left:cn +\cs_new_nopar:Npn \seq_pop:NN { \seq_pop_aux:nnNN \tl_set:Nn \tl_set:Nn } +\cs_generate_variant:Nn \seq_pop:NN {c} +\cs_new_eq:NN \seq_gpush:Nn \seq_gput_left:Nn +\cs_new_nopar:Npn \seq_gpop:NN { \seq_pop_aux:nnNN \tl_gset:Nn \tl_set:Nn } +\cs_generate_variant:Nn \seq_gpush:Nn {NV,No,c,Nv} +\cs_generate_variant:Nn \seq_gpop:NN {c} +\cs_new_eq:NN \seq_top:NN \seq_get:NN +\cs_new_eq:NN \seq_top:cN \seq_get:cN %% %% %% End of file `l3seq.sty'. |