Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by h1439878.stratoserver.net (8.14.4/8.14.4/Debian-2ubuntu2.1) with ESMTP id t7QCD0D8007207 for ; Wed, 26 Aug 2015 14:13:01 +0200 Received: from relay.uni-heidelberg.de ([129.206.100.212]) by mx-ha.gmx.net (mxgmx113) with ESMTPS (Nemesis) id 0MYK0D-1ZH9Ik0XKL-00V8fb for ; Wed, 26 Aug 2015 14:12:55 +0200 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 t7QCB1fE018252 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 26 Aug 2015 14:11:02 +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 t7PM15d7029230; Wed, 26 Aug 2015 14:11:01 +0200 Received: by LISTSERV.UNI-HEIDELBERG.DE (LISTSERV-TCP/IP release 16.0) with spool id 12516606 for LATEX-L@LISTSERV.UNI-HEIDELBERG.DE; Wed, 26 Aug 2015 14:11:01 +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 t7QCB1Ou000333 for ; Wed, 26 Aug 2015 14:11:01 +0200 Received: from ar-005-i191.relay.mailchannels.net (ar-005-i191.relay.mailchannels.net [162.253.144.73]) by relay2.uni-heidelberg.de (8.13.8/8.13.8) with ESMTP id t7QCAvlW032099 for ; Wed, 26 Aug 2015 14:11:00 +0200 X-Sender-Id: netnames|x-authuser|joseph.wright@morningstar2.co.uk Received: from smtp3.easily.co.uk (ip-10-220-9-73.us-west-2.compute.internal [10.220.9.73]) by relay.mailchannels.net (Postfix) with ESMTPA id 6ED6C511E for ; Wed, 26 Aug 2015 12:10:54 +0000 (UTC) X-Sender-Id: netnames|x-authuser|joseph.wright@morningstar2.co.uk Received: from smtp3.easily.co.uk (smtp3.easily.co.uk [10.45.8.167]) (using TLSv1 with cipher DHE-RSA-AES256-SHA) by 0.0.0.0:2500 (trex/5.5.1); Wed, 26 Aug 2015 12:10:55 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: netnames|x-authuser|joseph.wright@morningstar2.co.uk X-MailChannels-Auth-Id: netnames X-MC-Loop-Signature: 1440591055051:4031711526 X-MC-Ingress-Time: 1440591055051 Received: from [139.222.114.163] (port=54658 helo=[139.222.114.163]) by smtp3.easily.co.uk with esmtpa (Exim 4.43) id 1ZUZXX-0002Wa-PM for LATEX-L@LISTSERV.UNI-HEIDELBERG.DE; Wed, 26 Aug 2015 13:10:51 +0100 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> X-Enigmail-Draft-Status: N1110 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-AuthUser: joseph.wright@morningstar2.co.uk Message-ID: <55DDACCB.1070104@morningstar2.co.uk> Date: Wed, 26 Aug 2015 13:10:51 +0100 Reply-To: Mailing list for the LaTeX3 project Sender: Mailing list for the LaTeX3 project From: Joseph Wright Subject: Re: Catcode changes To: LATEX-L@LISTSERV.UNI-HEIDELBERG.DE In-Reply-To: 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:Nh/N6EzwGa8=:HwlYZasGEfZgvF9YXQSgPyDfo/ BDFOswZBrMdOIPwh2+UcbzmTpmbLkT5jE9J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 2.71 on 85.214.41.38 Status: R X-Status: X-Keywords: X-UID: 7842 On 26/08/2015 12:34, Bruno Le Floch wrote: > On 8/26/15, aparsloe wrote: >> On 25/08/2015 1:35 a.m., Joseph Wright wrote: >>> On 25/08/2015 07:05, Joseph Wright wrote: >>>> On 26/08/2015 00:44, aparsloe wrote: >>>>> (1) I wanted to use \tl_replace_all:Nnn on a token list that might >>>>> contain braced groups. Using \tl_set_rescan:Nnn to change the category >>>>> codes of { and } seemed the most direct way of proceeding. (Then >>>>> resetting the category codes after replacement with an empty setup.) >>>> I see what you mean (I have a similar case in siunitx, for historical >>>> reasons). We'll explore what we can do with this: there are >>>> mapping-based approaches one can imagine that will enter brace groups. >>>> (We do that for \tl_lower_case:n, for example). However, for a general >>>> 'search and replace' I'd be slightly wary as the TeX convention that >>>> stuff in brace groups is 'special' is quite prevalent. (Depending on >>>> performance requirements, you might also look at l3regex if you are >>>> doing the replacement only very rarely.) >>> It would be useful here to see what your real use case is, as that's >>> often illustrative. >>> -- >>> Joseph Wright >> 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'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