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 p0NNJxLc007213 for ; Mon, 24 Jan 2011 00:20:00 +0100 Received: (qmail 23303 invoked by alias); 23 Jan 2011 23:19:54 -0000 Delivered-To: GMX delivery to rainer.schoepf@gmx.net Received: (qmail invoked by alias); 23 Jan 2011 23:19:53 -0000 Received: from relay.uni-heidelberg.de (EHLO relay.uni-heidelberg.de) [129.206.100.212] by mx0.gmx.net (mx031) with SMTP; 24 Jan 2011 00:19:53 +0100 Received: from listserv.uni-heidelberg.de (listserv.uni-heidelberg.de [129.206.100.94]) by relay.uni-heidelberg.de (8.14.1/8.14.1) with ESMTP id p0NNHuLo024304 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 24 Jan 2011 00:17:56 +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 p0NN16g8006208; Mon, 24 Jan 2011 00:17:48 +0100 Received: by LISTSERV.UNI-HEIDELBERG.DE (LISTSERV-TCP/IP release 16.0) with spool id 852722 for LATEX-L@LISTSERV.UNI-HEIDELBERG.DE; Mon, 24 Jan 2011 00:17:48 +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 p0NNHmxL008210 for ; Mon, 24 Jan 2011 00:17:48 +0100 Received: from mail-gx0-f177.google.com (mail-gx0-f177.google.com [209.85.161.177]) by relay2.uni-heidelberg.de (8.13.8/8.13.8) with ESMTP id p0NNHguw014298 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=FAIL) for ; Mon, 24 Jan 2011 00:17:46 +0100 Received: by gxk21 with SMTP id 21so1769221gxk.22 for ; Sun, 23 Jan 2011 15:17:41 -0800 (PST) Received: by 10.150.52.2 with SMTP id z2mr3668140ybz.190.1295824661650; Sun, 23 Jan 2011 15:17:41 -0800 (PST) Received: from [10.0.1.109] (219-90-161-93.ip.adam.com.au [219.90.161.93]) by mx.google.com with ESMTPS id v7sm2379892ybe.15.2011.01.23.15.17.38 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 23 Jan 2011 15:17:40 -0800 (PST) Mime-Version: 1.0 (Apple Message framework v1081) Content-Type: text/plain; charset=us-ascii References: <201101230906.p0N96bln024353@comedy.dante.de> <4D3C4934.50606@morningstar2.co.uk> X-Mailer: Apple Mail (2.1081) X-Spam-Whitelist: Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by listserv.uni-heidelberg.de id p0NNHmxL008211 Message-ID: <22643B11-AE3F-4871-AD80-BA74EBFDFDB2@GMAIL.COM> Date: Mon, 24 Jan 2011 09:47:33 +1030 Reply-To: Mailing list for the LaTeX3 project Sender: Mailing list for the LaTeX3 project From: Will Robertson 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=5D7Q89H36p4U4jfdfC5HDevlx1X2sAZgAaLl3DbFfW0PXxL7WgvovMFXXSEPrACW/b9IW Qp+GhEViZlUW4mdBntgP1X8KwB5tjHCA/yxSZMu7BXBiPs3ujyaoi2xLHDqpg8dk65Dhpb3Lg0c1 iTjGg==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: 6569 On 24/01/2011, at 1:58 AM, Joseph Wright wrote: > I'm happy with the idea in principal, but not the names or the > implementation :-) You had me worried there for a second, but your implementation is just an optimisation of mine -- phew! At least we're on the same wavelength there :) Thanks for the feedback; exactly what I was hoping to hear. > On the names, we currently have \tl_elt_count:N, so should really follow > the model and have \clist_elt_count:N. On the other hand, I notice that > there are various other uses of 'element' in other functions. So perhaps > we'd be better having \tl_element_count:N and \clist_element_count:N, > and not using 'elt' at all. (We also need :c and :n variants.) If we were going to change the _elt_count one, wouldn't _length be the most sensible for all of them? > For \clist_nth:N, I'd prefer '\clist_element:N'. We don't want 'get' > here as that is used in non-expandable assignments (see \prop_get:NnN, > etc.). 'nth' is really awkward, I think. Sure, I agree here. > On the implementation, there are some things to think about. You've gone > for an implementation indexed from 1, which gives an error with 'out of > range' cases. In other places we've indexed from 0 (as TeX does for > \ifcase), and we need to cover negative numbers. I'd prefer to avoid two > loops, and also think that 'out-of-range' values should simply result in > an empty value, not an error. Oh yes -- bailing at the end of the list rather than explicitly checking sizes is a fine idea. For negative indices, I think they should actually be used to access elements from the end. > A couple of notes. I've gone for \int_compare:nNn for performance > reasons over \int_compare:n, Sure. Efficiency comes second after working implementation :) > 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. You mean avoiding the \int_eval:n inside the 'f' expansion so you get "n-1-1-1-1-1-1-1-1==0" as the test goes along? I doubt it matters too much in terms of efficiency, and this makes the code more readable, so I've changed it to this approach. * * * Based on all this, I've updated the SVN repository with a new version of the code (but haven't done the seq versions, yet). Cheers, -- Will