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 o8LBlJKP020183 for ; Tue, 21 Sep 2010 13:47:20 +0200 Received: (qmail 23702 invoked by alias); 21 Sep 2010 11:47:13 -0000 Delivered-To: GMX delivery to rainer.schoepf@gmx.net Received: (qmail invoked by alias); 21 Sep 2010 11:47:13 -0000 Received: from relay.uni-heidelberg.de (EHLO relay.uni-heidelberg.de) [129.206.100.212] by mx0.gmx.net (mx040) with SMTP; 21 Sep 2010 13:47:13 +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 o8LBjVlC021547 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 21 Sep 2010 13:45:32 +0200 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 o8LB1kaB018044; Tue, 21 Sep 2010 13:45:27 +0200 Received: by LISTSERV.UNI-HEIDELBERG.DE (LISTSERV-TCP/IP release 16.0) with spool id 457201 for LATEX-L@LISTSERV.UNI-HEIDELBERG.DE; Tue, 21 Sep 2010 13:45:27 +0200 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 o8LBjRJO025300 for ; Tue, 21 Sep 2010 13:45:27 +0200 Received: from ueamailgate01.uea.ac.uk (ueamailgate01.uea.ac.uk [139.222.131.184]) by relay.uni-heidelberg.de (8.14.1/8.14.1) with ESMTP id o8LBjBmj021207 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 21 Sep 2010 13:45:15 +0200 Received: from ueams01.uea.ac.uk (ueams01.uea.ac.uk [139.222.131.78]) by ueamailgate01.uea.ac.uk (8.13.8/8.13.8) with ESMTP id o8LBjBDR032623 for ; Tue, 21 Sep 2010 12:45:11 +0100 Received: from [139.222.201.121] by ueams01.uea.ac.uk with esmtp (Exim 4.69) (envelope-from ) id 1Oy1HX-0005iB-9A for LATEX-L@LISTSERV.UNI-HEIDELBERG.DE; Tue, 21 Sep 2010 12:45:07 +0100 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.2.8) Gecko/20100802 Thunderbird/3.1.2 MIME-Version: 1.0 References: <4C967C9B.5010706@gmx.de> <71ED7A5B-DE11-45D9-9785-95A1DC795080@gmail.com> <4C9724B4.3010301@residenset.net> <19607.26705.947540.499705@morse.mittelbach-online.de> <4C9840AB.4050805@gmx.de> <732A7500-5414-4818-87E3-33CB14463288@gmail.com> <4C98435A.1050507@gmx.de> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Bayes-Prob: 0.0001 (Score 0, tokens from: @@RPTN, outgoing) X-CanIt-Geo: ip=139.222.131.78; country=GB; region=I9; city=Norwich; latitude=52.6333; longitude=1.3000; http://maps.google.com/maps?q=52.6333,1.3000&z=6 X-CanItPRO-Stream: UEA:outgoing (inherits from UEA:default,base:default) X-Canit-Stats-ID: 58695503 - 0defadb10ff0 - 20100921 X-Scanned-By: CanIt (www . roaringpenguin . com) on 139.222.131.184 Message-ID: <4C989ACB.5060000@morningstar2.co.uk> Date: Tue, 21 Sep 2010 12:45:15 +0100 Reply-To: Mailing list for the LaTeX3 project Sender: Mailing list for the LaTeX3 project From: Joseph Wright Subject: Re: boolean expressions in ExplSyntaxNames To: LATEX-L@listserv.uni-heidelberg.de In-Reply-To: <4C98435A.1050507@gmx.de> Precedence: list List-Help: , List-Unsubscribe: List-Subscribe: List-Owner: List-Archive: X-GMX-Antispam: 0 (Mail was not recognized as spam); Detail=5D7Q89H36p77e5KAPs1l6v/Sb97LojnDtMgfETrECMLUO9erHzOJe+OynZRhvlGqb5A0X bbiCt2rAnnct/NAlbHMvoAL6GY+23tB3khNK7bp7qqSbssdDTHsQd8+gWzfjr4OMj5ambWQGofKK 3vIsQ==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: 6429 On 21/09/2010 06:32, Arno Trautmann wrote: >> Why not just use&& in the first place? > > Because of possible catcode-troubles? ;) > Or maybe such a list might be more useful for a xor operation. How does the following look? The Boolean expressions are the most basic versions (NOT takes one argument, others take two), but nesting seems to work fine. There is definitely less code to this than the current implementation, so there would be a performance gain. \documentclass{article} \usepackage{expl3} \ExplSyntaxOn \cs_set_nopar:Npn \bool_if:nT #1 { \tex_ifodd:D \bool_if_p:n {#1} \tex_expandafter:D \use:n \tex_else:D \tex_expandafter:D \use_none:n \tex_fi:D } \cs_set_nopar:Npn \bool_if:nF #1 { \tex_ifodd:D \bool_if_p:n {#1} \tex_expandafter:D \use_none:n \tex_else:D \tex_expandafter:D \use:n \tex_fi:D } \cs_set_nopar:Npn \bool_if:nTF #1 { \tex_ifodd:D \bool_if_p:n {#1} \tex_expandafter:D \use_i:nn \tex_else:D \tex_expandafter:D \use_ii:nn \tex_fi:D } \cs_set_nopar:Npn \bool_if_p:n #1 { \tex_number:D #1 ~ } \cs_set_nopar:Npn \bool_not_p:n #1 { \tex_ifnum:D \tex_number:D #1 = \c_true_bool \c_false_bool \tex_else:D \c_true_bool \tex_fi:D } \cs_set_nopar:Npn \bool_and_p:nn #1#2 { \tex_ifnum:D \tex_number:D #1 = \c_true_bool \tex_ifnum:D \tex_number:D #2 = \c_true_bool \c_true_bool \tex_else:D \c_false_bool \tex_fi:D \tex_else:D \c_false_bool \tex_fi:D } \cs_set_nopar:Npn \bool_or_p:nn #1#2 { \tex_ifnum:D \tex_number:D #1 = \c_true_bool \c_true_bool \tex_else:D \tex_ifnum:D \tex_number:D #2 = \c_true_bool \c_true_bool \tex_else:D \c_false_bool \tex_fi:D \tex_fi:D } \cs_set_nopar:Npn \bool_xor_p:nn #1#2 { \tex_ifnum:D \tex_number:D #1 = \c_true_bool \tex_ifnum:D \tex_number:D #2 = \c_true_bool \c_false_bool \tex_else:D \c_true_bool \tex_fi:D \tex_else:D \tex_ifnum:D \tex_number:D #2 = \c_true_bool \c_false_bool \tex_else:D \c_true_bool \tex_fi:D \tex_fi:D } \ExplSyntaxOff \begin{document} \ExplSyntaxOn \bool_if:nTF { \c_true_bool } { TRUE } { FALSE } ~ \bool_if:nTF { \bool_not_p:n { \c_true_bool } } { TRUE } { FALSE } ~ \bool_if:nTF { \bool_and_p:nn { \c_true_bool } { \bool_not_p:n { \bool_or_p:nn { \c_true_bool } { \c_false_bool } } } } { TRUE } { FALSE } ~ \bool_if:nTF { \bool_and_p:nn { \c_true_bool } { \bool_not_p:n { \bool_or_p:nn { \c_true_bool } { \c_false_bool } } } } { TRUE } { FALSE } ~ \bool_if:nTF { % LAZY EVALUATION \bool_and_p:nn { \int_compare_p:nNn { 1 } = { 1 } } { \bool_and_p:nn { \bool_if_p:n { \bool_or_p:nn { \intexpr_compare_p:nNn { 2 } = { 3 } } { \bool_or_p:nn { \intexpr_compare_p:nNn { 4 } = { 4 } } { \intexpr_compare_p:nNn { 1 } = { \ERROR } } % Skip } } } { \int_compare_p:nNn { 2 } = { 2 } } } } { TRUE } { FALSE } ~ \ExplSyntaxOff \end{document} -- Joseph Wright