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