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 p2ICiSOp011880 for ; Fri, 18 Mar 2011 13:44:29 +0100 Received: (qmail 20429 invoked by alias); 18 Mar 2011 12:44:23 -0000 Delivered-To: GMX delivery to rainer.schoepf@gmx.net Received: (qmail invoked by alias); 18 Mar 2011 12:44:23 -0000 Received: from relay2.uni-heidelberg.de (EHLO relay2.uni-heidelberg.de) [129.206.210.211] by mx0.gmx.net (mx003) with SMTP; 18 Mar 2011 13:44:23 +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 p2ICgJKe000631 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 18 Mar 2011 13:42: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 p2ICbEUD011272; Fri, 18 Mar 2011 13:42:11 +0100 Received: by LISTSERV.UNI-HEIDELBERG.DE (LISTSERV-TCP/IP release 16.0) with spool id 1219112 for LATEX-L@LISTSERV.UNI-HEIDELBERG.DE; Fri, 18 Mar 2011 13:42:11 +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 p2ICgB0J002468 for ; Fri, 18 Mar 2011 13:42:11 +0100 Received: from csep02.cliche.se (csep02.cliche.se [195.249.40.184]) by relay2.uni-heidelberg.de (8.13.8/8.13.8) with ESMTP id p2ICft8d000435 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 18 Mar 2011 13:42:00 +0100 Received: from nova.local (unknown [130.239.119.132]) by csep02.cliche.se (Postfix) with ESMTP id 2FA1D18665A for ; Fri, 18 Mar 2011 13:41:54 +0100 (CET) User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; sv-SE; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9 MIME-Version: 1.0 References: <905C5ED0-6639-4DEB-95AC-A2FCB2C4491D@gmail.com> <935A1EA2-C971-4A3A-8DF4-6F890E0CFB32@gmail.com> <5256FD2C-CD53-4FF0-A405-5B8B2781E5EC@gmail.com> <19843.17637.935263.780194@morse.mittelbach-online.de> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by listserv.uni-heidelberg.de id p2ICgB0J002469 Message-ID: <4D835315.3040004@residenset.net> Date: Fri, 18 Mar 2011 13:41:57 +0100 Reply-To: Mailing list for the LaTeX3 project Sender: Mailing list for the LaTeX3 project From: =?ISO-8859-1?Q?Lars_Hellstr=F6m?= Subject: Re: expl3's seq_pop_right etc. To: LATEX-L@listserv.uni-heidelberg.de In-Reply-To: <19843.17637.935263.780194@morse.mittelbach-online.de> Precedence: list List-Help: , List-Unsubscribe: List-Subscribe: List-Owner: List-Archive: X-GMX-Antispam: 0 (Mail was not recognized as spam); Detail=5D7Q89H36p4U4jfdfC5HDevlx1X2sAZg1MkugZcpwIdDb8z5l6KEaP+LdZ7QLw+5CKzyp k5HTLZ1v8wPRqFdQdQapWq9qz59Rr52fCiljKsM85i3sbXAJVBjnzZkoSL42zBmmwDa5vja6zT3o 7boow==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: 6686 Frank Mittelbach skrev 2011-03-18 12.41: > > - I'd like every "..._map_function:NN" to become > > "..._map_function:Nn", i.e. allow mapping several tokens at a time. It > > isn't difficult to adapt the code for that, and it would be quite > > practical, since among the mappings, only the "map_function" are > > expandable. For that reason, "\seq_map_function:NN" is not defined in > > the file I attach. > > Personally I don't find this very intuitive; if you map a function you map a > function name and that would mean N. Besides you would lose the ability to map > a constructed function name ie "c" though that is something you would seldom > need I guess. And it would be covered by applying a suitable \exp_args:... to the ..._map_function:... call, would it not? > If you map several tokens then this means that you either have a bunch of > static tokens plus a final token/function that picks up the argument. Or > alternatively you map a function with several arguments (and only the last one > is filled with items from the sequence) This is what /I/ would expect to use such a feature for. In some circles, it's called currying: construct an n-k arguments function from an n arguments function by passing it with the first k arguments already supplied. > or it is a mixture of both. None of > those scenarios feel right to me. From a programming aspect I would probably > always prefer to define my mapping function properly first and then apply it, > ie instead of > > ...map_function:Nn \l_foo_seq { \func:n } > > I would rather do > > \cs_new:Npn \map_func:n #1 { \func:n #1} > > ...map_function:NN \l_foo_seq \map_func:n And instead of ...map_function:Nn \l_foo_seq { \func:nn{foo} } rather do \cs_new:Npn \map_func:n #1 { \func:nn{foo}{#1} } ...map_function:NN \l_foo_seq \map_func:n ? The downside of this is that it hardwires the "foo" into a function body, when in practice it might be data that changes from call to call. You can of course redefine \map_func:n before every use, but it feels unelegant. > This has to be done anyway if the #1 needs to be somewhere other than at the > end, eg > > \cs_new:Npn \map_func:n #1 {\func:nnn {foo}{#1}{bar}} Not at all! In that case, you do \cs_new:Npn \exch_args:Nnnn #1 #2 #3 #4 { #1{#2}{#4}{#3} } ...map_function:Nn \l_foo_seq { \exch_args:Nnnn\func:nnn{foo}{bar} } (the stem "exch" is of course from the postscript operator which exchanges the top two operands on the stack) or possibly \cs_new:Npn \exchd_func:nnn #1 #2 #3 { \func:nnn{#1}{#3}{#2} } ...map_function:Nn \l_foo_seq { \exchd_func:nnn{foo}{bar} } but \exch_args:Nnnn is more elegant, since it can be reused in more places. Lars Hellström