Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) by h1439878.stratoserver.net (8.14.4/8.14.4/Debian-2ubuntu2.1) with ESMTP id t7QNBEaF019617 for ; Thu, 27 Aug 2015 01:11:15 +0200 Received: from relay2.uni-heidelberg.de ([129.206.210.211]) by mx-ha.gmx.net (mxgmx007) with ESMTPS (Nemesis) id 0MV1u1-1ZEV7Z2xAr-00YSDC for ; Thu, 27 Aug 2015 01:11:08 +0200 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 t7QN9FSQ000924 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 27 Aug 2015 01:09:16 +0200 Received: from listserv.uni-heidelberg.de (listserv.uni-heidelberg.de [127.0.0.1]) by listserv.uni-heidelberg.de (8.13.8/8.13.8) with ESMTP id t7QM1CPV009966; Thu, 27 Aug 2015 01:09:15 +0200 Received: by LISTSERV.UNI-HEIDELBERG.DE (LISTSERV-TCP/IP release 16.0) with spool id 12511249 for LATEX-L@LISTSERV.UNI-HEIDELBERG.DE; Thu, 27 Aug 2015 01:09:15 +0200 Received: from relay2.uni-heidelberg.de (relay2.uni-heidelberg.de [129.206.210.211]) by listserv.uni-heidelberg.de (8.13.8/8.13.8) with ESMTP id t7QN9F2A014025 for ; Thu, 27 Aug 2015 01:09:15 +0200 Received: from smtp3.clear.net.nz (smtp3.clear.net.nz [203.97.33.64]) by relay2.uni-heidelberg.de (8.13.8/8.13.8) with ESMTP id t7QN96GC000850 for ; Thu, 27 Aug 2015 01:09:09 +0200 Received: from mxin3-orange.clear.net.nz (lb1-srcnat.clear.net.nz [203.97.32.236]) by smtp3.clear.net.nz (CLEAR Net Mail) with ESMTP id <0NTP006KEPMCJK20@smtp3.clear.net.nz> for LATEX-L@listserv.uni-heidelberg.de; Thu, 27 Aug 2015 11:09:04 +1200 (NZST) Received: from 203-96-200-19.dsl.dyn.ihug.co.nz (HELO [127.0.0.1]) ([203.96.200.19]) by smtpin3.clear.net.nz with ESMTP; Thu, 27 Aug 2015 11:09:02 +1200 MIME-version: 1.0 Content-type: multipart/alternative; boundary=------------080308090900080907090708 X-Antivirus: avast! (VPS 150826-4, 26/08/2015), Outbound message X-Antivirus-Status: Clean References: <55DBB7F6.1070307@clear.net.nz> <55DABA1D.3050706@morningstar2.co.uk> <55DCFDF7.7080305@clear.net.nz> <55DC05BF.1040505@morningstar2.co.uk> <55DC28E8.9090405@morningstar2.co.uk> <55DDFD0A.4000901@clear.net.nz> <55DDACCB.1070104@morningstar2.co.uk> User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.0.1 Message-ID: <55DF523F.2050905@clear.net.nz> Date: Thu, 27 Aug 2015 11:09:03 -0700 Reply-To: Mailing list for the LaTeX3 project Sender: Mailing list for the LaTeX3 project From: aparsloe Subject: Re: Catcode changes To: LATEX-L@LISTSERV.UNI-HEIDELBERG.DE In-Reply-To: <55DDACCB.1070104@morningstar2.co.uk> Precedence: list List-Help: , List-Unsubscribe: List-Subscribe: List-Owner: List-Archive: Envelope-To: X-GMX-Antispam: 0 (Mail was not recognized as spam); Detail=V3; X-GMX-Antivirus: 0 (no virus found) X-UI-Filterresults: notjunk:1;V01:K0:bAOM52uo7ws=:T6kWHp6SSIZxPi1eI0/EwvnwA5 oig9cbUTluLIaqu1fWvF+6/oNR1IoEyNVTdblaqy2fs28G4NMkkm+l31AK+CZ4TtGytwYy/34 vSBflE3oNeO4NOh3MG1YCRlEZHXzhjQPWGqzhCfnUBy9rtEto3JGYS2aArvJxL1QhXY117Buu dGXaxobrepI6rP78UaKVzWhsviUxkRtAMX/KnlEZ7Sq+MOXsmpTcg8vheQVc1maNJwIabhg1R Lro2Zo8Z7DC8pE5orgbMewxSTYMBkjyfdZtDo+LfgZ2sp9QLzDT/zxivZ70yjt0EJ2alrPw1W 45mvukJ6y9aHRQrYWfpcbR0jj/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T09LZlvUpin4wteQaNV1jITTl4nF0lhm2fd/Gbvq+av94EseI4RL9pxAPPDOsNj5Q L8sBdKHEM1ocvb/9XbrzzAWCiIxR1dKcQyo52w/4fYYolL33Dz X-UI-Loop:V01:qxrUHYAsDKI=:SjiQt97wcfoTRh+ikPZovpQ7CDNaTdpRIn5FeqwH2nQ= X-UI-Out-Filterresults: notjunk:1;V01:K0:2pFQR/X6uwU=:/Obbonz0CgowsAj7gU7bhW V2UVzjKkxkZp94AE0mxL40Hh2ifUMNO8TE2Hh/BWIxKFtX0UPkiPfBmKH0FwAjrsY4jAuYrIU R86Yw+/zChfRhR3K3e3369fxInrwZF3AkxgNt2AF/1qEf9VPXrHyLNTCzCZQYdaXiOTX5OV/i dA5cJT8DZPZ99doUkrbKvspQj02orvvwBQOPB++ROrtjR5NViImV2MeGwAY/f/PlpWgLJ8blt 92EjTQXKWzHPb7NRt+X4y53BjVk71A3deNsjZn0hNJkS056+ZC7HfwE162Ydj/yQpGF6Houcl v5TE35Ujt4BhyVd+scUDE97egeX73u7LIVDOVWO/HgGprx/q1ynDBYdlUuQOWL2Aa0iJba/+y EFI9eJfK9T38Zx0EyHVB9hXuXGsNjbPUV3fdp/tM0nyhfwgm+J4UmN41m/Ho4crod3RDIDWqp vmiRk1lWT73DaOw+wV3okO5krn6+PFM4C6I/ESl+1YiSOlpuwHBb X-Scanned-By: MIMEDefang 2.71 on 85.214.41.38 Status: R X-Status: X-Keywords: X-UID: 7848 This is a multi-part message in MIME format. --------------080308090900080907090708 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit On 26/08/2015 5:10 a.m., Joseph Wright wrote: > On 26/08/2015 12:34, Bruno Le Floch wrote: >> Thank you for the responses. I was remiss. I didn't make it clear that >> looking inside braced groups was not the concern, rather to replace (or >> remove) a list of tokens that might include braced groups. I've been >> reworking the code of a package that turns latex expressions into >> expressions that can be digested by l3fp. In fact, this particular issue >> has now been reworked away, but the problem had been to remove a varying >> expression, e.g. \sqrt{123} or \frac{1-x}{1+x}, from the initial >> segment of a formula. Rescanning { and } to "other" allowed me to use >> \tl_remove:Nn successfully. Although I can think of other means of doing >> this, they seem cumbersome by comparison. >> >> Andrew >> \tl_set:No \l_result_tl { \use_none:nn \sqrt{123} + 123 } >> >> could be a better approach in many cases, no? >> >> Bruno I hadn't thought of the \use_none:... functions. (There is much of expl3 which is *not* at my fingertips.) Thank you, and I see that they can absorb up to 9 tokens. > I'm not quite clear if the outcome needs to be that the calculation > remains the same :-) For the simple case of 'drop the \sqrt', presumably > some wrapper is needed > > \cs_new_protected:Npn \my_calc:n #1 > { > \tl_set:Nn \l__my_tl {#1} > \tl_replace_all:Nnn \l__my_tl { \sqrt } { \use_none:n } > % Further replacements > \tl_set:Nx \l__my_tl { \l__my_tl } > } > > I'd though probably go for something like > > \cs_new_protected:Npn \my_calc:n #1 > { > \group_begin: > \cs_set:Npn \sqrt ##1 { sqrt( ##1 ) } > % Further replacements > \fp_set:Nn \l__my_fp {#1} > \exp_args:NNNV \group_end: > \fp_set:Nn \l__my_fp \l__my_fp > } > > i.e. set up the various TeX commands to convert expandably into their fp > equivalents, then set an fp before 'smuggling' the result out the group. > > Depending on the exact spec these approaches could be combined: for > example \frac{1-x}{1+x} clearly has to go, which might be done with > > \cs_set_eq:NN \frac \use_none:nn > > in the second approach or > > \tl_replace_all:Nnn \l__my_tl { \frace} { \use_none:nn } > > in the first. > > The key point is none of this needs rescanning :-) > > Joseph OK, at first glance I was a bit overwhelmed but having had a little time to see what you are doing, this is helpful. Dare I continue the theme? For instance I have used rescanning of ( and ) to "group begin" and "group end" to obtain the parenthesised arguments of functions "at one gulp", e.g. \max() or the parenthesised part (the inner sum) of \sum_{k=0}^{\infty}\frac{(-1)^{k}}{2^{k+1}}\left(\sum_{n=0}^{k}(-1)^{n}\binom{k}{n}\frac{1}{(k-n)!}\right) (= 1/e). Finally, in arguing against changing catcodes you are assuming a greater knowledge of TeX than I possess. There must be a reason for this deprecation. The great joy of discovering expl3 was that it made TeX programming available to someone familiar with basic (or even, dare I say it, line-numbered BASIC) programming concepts but with only a meagre knowledge of TeX. (So, for instance, I wonder why you use \cs_new_protected:Npn above rather than \cs_new:Npn or \cs_new_nopar:Npn. Interfaces3.pdf is thin on such matters.) Andrew LyX Document --- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus --------------080308090900080907090708 Content-Type: text/html; charset=windows-1252 Content-Transfer-Encoding: 7bit

On 26/08/2015 5:10 a.m., Joseph Wright wrote:
On 26/08/2015 12:34, Bruno Le Floch wrote:
Thank you for the responses. I was remiss. I didn't make it clear that
looking inside braced groups was not the concern, rather to replace (or
remove) a list of tokens that might include braced groups. I've been
reworking the code of a package that turns latex expressions into
expressions that can be digested by l3fp. In fact, this particular issue
has now been reworked away, but the problem had been to remove a varying
expression, e.g. \sqrt{123}  or \frac{1-x}{1+x}, from the initial
segment of a formula. Rescanning { and } to "other" allowed me to use
\tl_remove:Nn successfully. Although I can think of other means of doing
this, they seem cumbersome by comparison.

Andrew
\tl_set:No \l_result_tl { \use_none:nn \sqrt{123} + 123 }

could be a better approach in many cases, no?

Bruno

I hadn't thought of the \use_none:... functions. (There is much of expl3 which is *not* at my fingertips.) Thank you, and I see that they can absorb up to 9 tokens.

I'm not quite clear if the outcome needs to be that the calculation
remains the same :-) For the simple case of 'drop the \sqrt', presumably
some wrapper is needed

    \cs_new_protected:Npn \my_calc:n #1
      {
        \tl_set:Nn \l__my_tl {#1}
        \tl_replace_all:Nnn \l__my_tl { \sqrt } { \use_none:n }
        % Further replacements
        \tl_set:Nx \l__my_tl { \l__my_tl }
      }

I'd though probably go for something like

    \cs_new_protected:Npn \my_calc:n #1
      {
        \group_begin:
         \cs_set:Npn \sqrt ##1 { sqrt( ##1 ) }
         % Further replacements
         \fp_set:Nn \l__my_fp {#1}
        \exp_args:NNNV \group_end:
        \fp_set:Nn \l__my_fp \l__my_fp
      }

i.e. set up the various TeX commands to convert expandably into their fp
equivalents, then set an fp before 'smuggling' the result out the group.

Depending on the exact spec these approaches could be combined: for
example \frac{1-x}{1+x} clearly has to go, which might be done with

    \cs_set_eq:NN \frac \use_none:nn

in the second approach or

    \tl_replace_all:Nnn \l__my_tl { \frace} { \use_none:nn }

in the first.

The key point is none of this needs rescanning :-)

Joseph
OK, at first glance I was a bit overwhelmed but having had a little time to see what you are doing, this is helpful.

Dare I continue the theme? For instance I have used rescanning of ( and ) to "group begin" and "group end" to obtain the parenthesised arguments of functions "at one gulp", e.g.

\max(<variable number of terms>)

or the parenthesised part (the inner sum) of

LyX Document



Avast logo

This email has been checked for viruses by Avast antivirus software.
www.avast.com


--------------080308090900080907090708--