LATEX-L Archives

Mailing list for the LaTeX3 project

LATEX-L@LISTSERV.UNI-HEIDELBERG.DE

Options: Use Forum View

Use Monospaced Font
Show HTML Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Bruno Le Floch <[log in to unmask]>
Reply To:
Mailing list for the LaTeX3 project <[log in to unmask]>
Date:
Sun, 13 Mar 2011 19:18:35 -0400
Content-Type:
text/plain
Parts/Attachments:
text/plain (43 lines)
>> So I'm generally in favour of this suggestion. But I wonder if there is
>> some downside to using braces that I'm not experienced enough to see. (I
>> can't think off the top of my head of another stack-like data structures
>> in TeX that uses braces.) Can anyone comment further on this?
>
> Well, to answer my own question, here's a function I'm currently using in an
> expl3 translation of the NFSS: (sorry for the long-ish code chunk)

It is very easy to convert from the braced to the delimited version using

    \cs_set:Npn \seq_elt:n #1 {\seq_elt:w #1 \seq_elt_end:}

See code below for the full code corresponding to what you wrote.


\RequirePackage{expl3}
\ExplSyntaxOn
% Assuming seqs of the form
\tl_new:Nn \l_foo_Seq {\seq_elt:n {a/b-c} \seq_elt:n {A/BC-DE}}

% We can always convert back to the old form using
\cs_new:Npn \seq_elt_new_to_old:n #1 {\seq_elt:w #1 \seq_elt_end:}

% "\Seq_map_inline:Npn" <seq> <params> <function definition>
\cs_new_protected_nopar:Npn \Seq_map_inline:Npn #1#2# {
  \Seq_map_inline_aux:Nnn #1 {#2}
}
\cs_new:Npn \Seq_map_inline_aux:Nnn #1#2#3 {
  \cs_set_eq:NN \seq_elt:n \seq_elt_new_to_old:n
  \cs_set:Npn \seq_elt:w #2 \seq_elt_end: {#3}
  #1
  \use_none:nnn \seq_elt_end: \q_break {} % break in the "new" way.
  \cs_set_eq:NN \seq_elt:w \ERROR
  \cs_set_eq:NN \seq_elt:n \ERROR
}

% Example
\tl_set:Nn \l_foo_Seq {\seq_elt:n {a/b-c} \seq_elt:n {A/BC-DE}}
\Seq_map_inline:Npn \l_foo_Seq #1/#2-#3 {\tl_show:n {#1|#2|#3}}


-- Bruno

ATOM RSS1 RSS2