Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by h1439878.stratoserver.net (8.14.2/8.14.2/Debian-2build1) with ESMTP id r616hACe018403 for ; Mon, 1 Jul 2013 08:43:12 +0200 Received: from relay2.uni-heidelberg.de ([129.206.210.211]) by mx-ha.gmx.net (mxgmx107) with ESMTP (Nemesis) id 0Lhl77-1UOamO06hl-00moeB for ; Mon, 01 Jul 2013 08:43:05 +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 r616eMqK032114 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 1 Jul 2013 08:40:22 +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 r5UM191l015289; Mon, 1 Jul 2013 08:40:21 +0200 Received: by LISTSERV.UNI-HEIDELBERG.DE (LISTSERV-TCP/IP release 16.0) with spool id 10171619 for LATEX-L@LISTSERV.UNI-HEIDELBERG.DE; Mon, 1 Jul 2013 08:40:21 +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 r616UKbm005460 for ; Mon, 1 Jul 2013 08:30:20 +0200 Received: from mail-wi0-f172.google.com (mail-wi0-f172.google.com [209.85.212.172]) by relay2.uni-heidelberg.de (8.13.8/8.13.8) with ESMTP id r616UDL2029048 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=FAIL) for ; Mon, 1 Jul 2013 08:30:16 +0200 Received: by mail-wi0-f172.google.com with SMTP id c10so2678380wiw.5 for ; Sun, 30 Jun 2013 23:30:13 -0700 (PDT) X-Received: by 10.180.21.141 with SMTP id v13mr10890757wie.10.1372660213331; Sun, 30 Jun 2013 23:30:13 -0700 (PDT) Received: from palladium.home (host86-132-58-46.range86-132.btcentralplus.com. [86.132.58.46]) by mx.google.com with ESMTPSA id fo10sm14025947wib.8.2013.06.30.23.30.10 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 30 Jun 2013 23:30:12 -0700 (PDT) User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:17.0) Gecko/20130620 Thunderbird/17.0.7 MIME-Version: 1.0 References: X-Enigmail-Version: 1.5.1 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Message-ID: <51D121F7.9050308@morningstar2.co.uk> Date: Mon, 1 Jul 2013 07:30:15 +0100 Reply-To: Mailing list for the LaTeX3 project Sender: Mailing list for the LaTeX3 project From: Joseph Wright Subject: Re: Defining \bool_case:nn 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:l2Hzj8pmJ9w=:YEU8bHOWeV/fr/boi8Wv3g gacjhNA7s+n3uVzjquXWaDrNx/MS9QEq2ss14ncVKuFgPyf/M3hBIk9cAObjUwHqLsuG89w Jcz4lLA0eSXEXhrlx0axGkiKDhxP4YnEJnSCCXzYyWRC4KhMGlRoKij94V1cwnTJrRzmpin VI7A5FpE10DvmZKwuglgSrrzPyXps6egGOg1k+nDvQkBXjA84gex91OUuNwRML7m57Wq4D9 c2q1BlUJQpGrkk0ANIkN8js3njXDIM+HieKxLP8bNAzv3QeSUDidJ7TgyQDTvh8AcLdzn0I 5UeyIDG3pR8s2japNFW8WdHoqnUQGXb78/TSzB5dx0ONz0uoQL02Hwj4hpeEG6FpQV0tIjz k345mf/di859wB6RaHMa7PaoknjbKLTcZ6VrrskL3osOVD1xEn+cUqqUbfmJ47sNwHlB1RM iX9BvRreRxA/mtqX6gkC8oWx926MyqbTD3RCuT/0TI/9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dbGYroQR8 NMpTOixUIUyLHm2VVLpFrEZvKJLYwx2e3K6hLM2Ouc4+HJMj8dm9kC1qDJc4vERf8dXa68D gp9hTEktD X-UI-Loop:V01:ihyVrAr/I04=:5F/PpnuSKRnEPXJqw/OhI4ssXLcXN35VNRWyKQGtP88= Status: R X-Status: X-Keywords: X-UID: 7210 On 27/06/2013 17:42, Joel C. Salomon wrote: > Building on the TeX.SE posts "Is there a \bool_case:Nnn?" > (http://tex.stackexchange.com/q/121074/2966) and Joseph Wright's > answer to "How do the \xx_case: functions work?" > (http://tex.stackexchange.com/q/121390/2966), here is \bool_case:nn, > proposed for addition: > > \documentclass{minimal} > \usepackage{expl3, xparse} > > \ExplSyntaxOn > > \cs_new:Npn \bool_case:nn #1#2 > { > \tex_romannumeral:D > \__bool_case:w #1 \c_true_bool {#2} \q_recursion_stop > } > \cs_new:Npn \__bool_case:w #1#2 > { > \bool_if:nTF { #1 } > { \__bool_case_end:nw {#2} } > { \__bool_case:w } > } > \cs_new_eq:NN \__bool_case_end:nw \__prg_case_end:nw > > \NewDocumentCommand \testboolcase {} > { > \bool_set_false:N \l_tmpa_bool > \bool_set_true:N \l_tmpb_bool > > \bool_case:nn > { > \l_tmpa_bool { false;~ can't~ happen } > \l_tmpb_bool { true;~ should~ happen } > } > { else;~ can't~ happen } > } > > \NewDocumentCommand \testboolcaseelse {} > { > \bool_set_false:N \l_tmpa_bool > \bool_set_true:N \l_tmpb_bool > > \bool_case:nn > { > \l_tmpa_bool { false;~ can't~ happen } > { !\l_tmpb_bool } { false;~ can't~ happen } > } > { else;~ should~ happen } > } > > \ExplSyntaxOff > > \begin{document} > \testboolcase > > \testboolcaseelse > \end{document} I'm not sure I see the need for this. In the other 'case' functions, at most exactly one case can be true \int_case:nnn { #1 } { { 1 } { stuff } { 2 } ... However, in \bool_case:nn you stop at the first case that happens to be true. That means that order matters for the result, which isn't what happens in the other case functions. -- Joseph Wright