Extend your language: Difference between revisions

Content added Content deleted
m (→‎{{header|Wren}}: Changed to Wren S/H)
Line 2,007: Line 2,007:


=={{header|langur}}==
=={{header|langur}}==
Langur doesn't currently have macros, but the following will otherwise accomplish the task, using the fact that a given expression may accept multiple test expressions. No extension of the language is necessary. This is not limited to 2 conditions.
Langur doesn't have macros, but the following will otherwise accomplish the task, using the fact that a switch expression may accept multiple test expressions. No extension of the language is necessary. This is not limited to 2 conditions.


We could use the nxor (logical equivalence) operator to test truthiness.
We could use the nxor (logical equivalence) operator to test truthiness.


<syntaxhighlight lang="langur">given .x nxor, .y nxor {
<syntaxhighlight lang="langur">switch[and] .x nxor, .y nxor {
case true: ... # both true
case true: ... # both true
case true, false: ... # first true, second false
case true, false: ... # first true, second false
Line 2,020: Line 2,020:
To test directly for Boolean values (not truthiness), we could use the default == comparison.
To test directly for Boolean values (not truthiness), we could use the default == comparison.


<syntaxhighlight lang="langur">given .x, .y {
<syntaxhighlight lang="langur">switch[and] .x, .y {
case true: ... # both true
case true: ... # both true
case true, false: ... # first true, second false
case true, false: ... # first true, second false