LATEX-L Archives

Mailing list for the LaTeX3 project

LATEX-L@LISTSERV.UNI-HEIDELBERG.DE

Options: Use Forum View

Use Monospaced Font
Show Text 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:
Will Robertson <[log in to unmask]>
Reply To:
Mailing list for the LaTeX3 project <[log in to unmask]>
Date:
Mon, 14 Mar 2011 09:22:05 +1030
Content-Type:
text/plain
Parts/Attachments:
text/plain (44 lines)
On 14/03/2011, at 8:44 AM, Will Robertson wrote:

> 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)


% \begin{function}{\seq_map_inline:Npn}
% \begin{syntax}
% "\seq_map_inline:Npn" <seq> <params> <function definition>
% \end{syntax}
% Applies the <function definition> to each element of <seq>
% using delimited arguments defined by <params>.
%
% Note that each element is internally delimited so argument matching
% will be `greedy': writing "\seq_map_inline:Npn \foo #1,#2 {[#1,#2]}"
% for element "abc,def" will print `[abc,def]'. Which may or may not seem
% natural to you, depending how familiar you are with \TeX's delimited
% arguments.
%
% For this reason this function is not broadly advertised ":)"
% \end{function}
%
%
% \begin{macro}{\seq_map_inline:Npn}
% When a "seq" contains multiple pieces of information.
% (Perhaps I should be using a "prop" instead; to consider!)
%    \begin{macrocode}
\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:Npn \seq_elt:w #2 \seq_elt_end: {#3}
  #1 \use_none:n \q_stop
  \cs_set_eq:NN \seq_elt:w \ERROR
}
%    \end{macrocode}
% \end{macro}


Now you could argue that I'm using the wrong data structure here (perhaps a property list would be better) but there you go. I'm not certain we want to support this kind of use, but the current delimited structure of "seq"s sure has come in handy in this particular situation.

Will

ATOM RSS1 RSS2