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 q16BeTlJ013513 for ; Mon, 6 Feb 2012 12:40:30 +0100 Received: (qmail 10756 invoked by alias); 6 Feb 2012 11:40:24 -0000 Delivered-To: GMX delivery to rainer.schoepf@gmx.net Received: (qmail invoked by alias); 06 Feb 2012 11:40:24 -0000 Received: from relay2.uni-heidelberg.de (EHLO relay2.uni-heidelberg.de) [129.206.210.211] by mx0.gmx.net (mx060) with SMTP; 06 Feb 2012 12:40:24 +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 q16BcJU4023067 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 6 Feb 2012 12:38: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 q16BbZ27014479; Mon, 6 Feb 2012 12:38:19 +0100 Received: by LISTSERV.UNI-HEIDELBERG.DE (LISTSERV-TCP/IP release 16.0) with spool id 1981666 for LATEX-L@LISTSERV.UNI-HEIDELBERG.DE; Mon, 6 Feb 2012 12:36:31 +0100 Received: from relay.uni-heidelberg.de (relay.uni-heidelberg.de [129.206.100.212]) by listserv.uni-heidelberg.de (8.13.1/8.13.1) with ESMTP id q16BaVXX004497 for ; Mon, 6 Feb 2012 12:36:31 +0100 Received: from mail-lpp01m010-f49.google.com (mail-lpp01m010-f49.google.com [209.85.215.49]) by relay.uni-heidelberg.de (8.14.1/8.14.1) with ESMTP id q16BaOv9022954 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=FAIL) for ; Mon, 6 Feb 2012 12:36:29 +0100 Received: by laam7 with SMTP id m7so4241189laa.22 for ; Mon, 06 Feb 2012 03:36:24 -0800 (PST) MIME-Version: 1.0 Received: by 10.152.108.49 with SMTP id hh17mr9382384lab.0.1328528184027; Mon, 06 Feb 2012 03:36:24 -0800 (PST) Received: by 10.152.13.106 with HTTP; Mon, 6 Feb 2012 03:36:23 -0800 (PST) References: <20120203151218.GA30208@csmvddesktop> <4F2BFFA6.1020306@morningstar2.co.uk> <20120203155926.GA30436@csmvddesktop> <20120205160826.GA6939@csmvddesktop> <20120206054259.GB9462@csmvddesktop> <20120206105103.GA10777@csmvddesktop> <20120206111933.GA11183@csmvddesktop> Content-Type: text/plain; charset=ISO-8859-1 X-Spam-Whitelist: Message-ID: Date: Mon, 6 Feb 2012 06:36:23 -0500 Reply-To: Mailing list for the LaTeX3 project Sender: Mailing list for the LaTeX3 project From: Bruno Le Floch Subject: Re: Mapping Functions Versions for All and Some To: LATEX-L@listserv.uni-heidelberg.de In-Reply-To: <20120206111933.GA11183@csmvddesktop> Precedence: list List-Help: , List-Unsubscribe: List-Subscribe: List-Owner: List-Archive: X-GMX-Antispam: 0 (BackTrace mail analyze); Detail=5D7Q89H36p4L00VTXC6D4q0N+AH0PUCnGL2vqOgpaBYL16oitsMrgDt/NQNpSCZFFjDOy 97xb7Zpf+wZnd5ZXNcvLDXR3Wg3wRjdQbwEMh8=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: 7029 > In the equivalent of my recurrence equations implementation, the > macro \f:n is defined _after_ the substitution. The error complains > about \f:n not being defined. Defining \f:n _before_ the substitution > works fine. The problem is that you \tl_use:N \l_expr_tl before defining \f:n. If you look at which line the error occurs, this is the line. To display a token list to the terminal (or log file), use one of the lines \tl_show:N \l_expr_tl \iow_term:x { \tl_to_str:N \l_expr_tl } \iow_log:x { \tl_to_str:N \l_expr_tl } Those differ in the details, but give you the information without expanding the token list: the last two lines convert the token list to a string of characters before printing them to the terminal or the log file. On the other hand, \tl_use:N is like typing the token list in your file. It will then be run as normal code, in particular expanding macros, including \f:n which is not defined yet. > In my recurrence equation implementation, defining \f:n _after_ the > substitution is possible, but it requires a bit more work. Does \f:n > have to be known at substitution time? It does not have to be defined at substitution time, but at use time. See below. -- \documentclass{article} \usepackage{xparse,l3regex} \begin{document} \ExplSyntaxOn \tl_new:N \l_name_tl \tl_set:Nn \l_name_tl {f} \tl_new:N \l_expr_tl \tl_set:Nn \l_expr_tl {f{i}} \iow_term:x { before:~\tl_to_str:N \l_expr_tl } \iow_term:x { and~\tl_to_str:N \l_name_tl } \regex_replace_all:nnN {\b\u{l_name_tl}\b} {\c{\u{l_name_tl}:n}} \l_expr_tl \iow_term:x { after:~\tl_to_str:N \l_expr_tl } \iow_term:x { and~\tl_to_str:N \l_name_tl } % Define \f:n before using it! :-) \cs_new_nopar:cpx { \l_name_tl :n } #1{} after(\tl_use:N \l_expr_tl) \end{document} -- Regards, Bruno