Received: from mx0.gmx.net (mx0.gmx.net [213.165.64.100]) by h1439878.stratoserver.net (8.14.2/8.14.2/Debian-2build1) with SMTP id p0NGYOuj025652 for ; Sun, 23 Jan 2011 17:34:25 +0100 Received: (qmail 8951 invoked by alias); 23 Jan 2011 16:34:18 -0000 Delivered-To: GMX delivery to rainer.schoepf@gmx.net Received: (qmail invoked by alias); 23 Jan 2011 16:34:18 -0000 Received: from relay2.uni-heidelberg.de (EHLO relay2.uni-heidelberg.de) [129.206.210.211] by mx0.gmx.net (mx013) with SMTP; 23 Jan 2011 17:34:18 +0100 Received: from listserv.uni-heidelberg.de (listserv.uni-heidelberg.de [129.206.100.94]) by relay2.uni-heidelberg.de (8.13.8/8.13.8) with ESMTP id p0NGVKmx018694 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 23 Jan 2011 17:31:20 +0100 Received: from listserv.uni-heidelberg.de (localhost.localdomain [127.0.0.1]) by listserv.uni-heidelberg.de (8.13.1/8.13.1) with ESMTP id p0NC14LE017349; Sun, 23 Jan 2011 17:31:15 +0100 Received: by LISTSERV.UNI-HEIDELBERG.DE (LISTSERV-TCP/IP release 16.0) with spool id 857757 for LATEX-L@LISTSERV.UNI-HEIDELBERG.DE; Sun, 23 Jan 2011 17:31:15 +0100 Received: from relay2.uni-heidelberg.de (relay2.uni-heidelberg.de [129.206.210.211]) by listserv.uni-heidelberg.de (8.13.1/8.13.1) with ESMTP id p0NGVF68010902 for ; Sun, 23 Jan 2011 17:31:15 +0100 Received: from lon1-post-2.mail.demon.net (lon1-post-2.mail.demon.net [195.173.77.149]) by relay2.uni-heidelberg.de (8.13.8/8.13.8) with ESMTP id p0NGV5nh018575 for ; Sun, 23 Jan 2011 17:31:09 +0100 Received: from morningstar2.demon.co.uk ([80.176.134.7] helo=palladium.local) by lon1-post-2.mail.demon.net with esmtp (Exim 4.69) id 1Ph2qH-0006zz-b7; Sun, 23 Jan 2011 16:31:05 +0000 User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-GB; rv:1.9.2.13) Gecko/20101207 Thunderbird/3.1.7 MIME-Version: 1.0 References: <201101230906.p0N96bln024353@comedy.dante.de> <4D3C4934.50606@morningstar2.co.uk> X-Enigmail-Version: 1.1.1 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Message-ID: <4D3C57C8.90006@morningstar2.co.uk> Date: Sun, 23 Jan 2011 16:31:04 +0000 Reply-To: Mailing list for the LaTeX3 project Sender: Mailing list for the LaTeX3 project From: Joseph Wright Subject: Re: \clist_length:N and \clist_nth:N To: LATEX-L@listserv.uni-heidelberg.de In-Reply-To: <4D3C4934.50606@morningstar2.co.uk> Precedence: list List-Help: , List-Unsubscribe: List-Subscribe: List-Owner: List-Archive: X-GMX-Antispam: 0 (Mail was not recognized as spam); Detail=5D7Q89H36p77e5KAPs1l6v/Sb97LojnDtMgfETrECMLUO9erHzOJe+OynZRhvlGqb5A0X bbiCt2rAnnct/NAlbHMvoAL6GY+23tB3khNK7au3fkL89Y026H2WJg1zsjGg0I0r5V9ldzzR5wBB /r19Q==V1; X-Resent-By: Forwarder X-Resent-For: rainer.schoepf@gmx.net X-Resent-To: rainer@rainer-schoepf.de Status: R X-Status: X-Keywords: X-UID: 6568 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