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:
Joseph Wright <[log in to unmask]>
Reply To:
Mailing list for the LaTeX3 project <[log in to unmask]>
Date:
Sun, 23 Jan 2011 16:31:04 +0000
Content-Type:
text/plain
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