LATEX-L Archives

Mailing list for the LaTeX3 project

LATEX-L@LISTSERV.UNI-HEIDELBERG.DE

Options: Use Classic View

Use Monospaced Font
Show HTML Part by Default
Condense Mail Headers

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

Print Reply
Sender: Mailing list for the LaTeX3 project <[log in to unmask]>
Date: Sun, 23 Jan 2011 16:31:04 +0000
Reply-To: Mailing list for the LaTeX3 project <[log in to unmask]>
Message-ID: <[log in to unmask]>
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
In-Reply-To: <[log in to unmask]>
Content-Type: text/plain; charset=ISO-8859-1
From: Joseph Wright <[log in to unmask]>
Parts/Attachments: text/plain (27 lines)
On 23/01/2011 15:28, Joseph Wright wrote:
>   \cs_new_nopar:Npn \clist_element:Nn #1#2 {
>     \exp_args:No \clist_element:nn {#1} {#2}
>   }
>   \cs_new:Npn \clist_element:nn #1#2 {
>     \int_compare:nNnF {#2} < { 0 }
>       {
>         \clist_element_aux:nw {#2} #1
>           , \q_recursion_tail \q_recursion_stop
>       }
>   }
>   \cs_new:Npn \clist_element_aux:nw #1#2 , #3 {
>     \int_compare:nNnTF {#1} = { 0 }
>       { \use_i_delimit_by_q_recursion_stop:nw {#2} }
>       {
>         \quark_if_recursion_tail_stop:n {#3}
>         \clist_element_aux:nw { #1 - 1 } #3
>       }
>   }

A couple of notes. I've gone for \int_compare:nNn for performance
reasons over \int_compare:n, and I'd probably use the expansion of
\int_eval:n in the 'count' functions, so that it only requires two
expansions to get to the result rather than three.
-- 
Joseph Wright

ATOM RSS1 RSS2