Logical operations: Difference between revisions
→{{header|langur}}
imported>Brie (Add Nu) |
Langurmonkey (talk | contribs) |
||
(4 intermediate revisions by 3 users not shown) | |||
Line 911:
print "not a: ", !a, "\n"
}</syntaxhighlight>
=={{header|Binary Lambda Calculus}}==
Minimal definitions of the logical operations in lambda calculus are: and = <code>\a\b.a b a</code>, or = <code>\a\b.a a b</code>, not = <code>\b\x\y.b y x</code>. In BLC these are <code>00 00 01 01 110 10 110</code>, or = <code>00 00 01 01 110 110 10</code>, not = <code>00 00 00 01 01 1110 10 110</code> respectively.
=={{header|BQN}}==
Line 2,241 ⟶ 2,244:
=={{header|langur}}==
The logical operators in langur compare the "truthiness" of the left and right operands and do not require Booleans
The operators and, or, nand, nor, and?, or?, nand?, nor?, xor?, and nxor? are short-circuiting.
Line 2,247 ⟶ 2,250:
Operators that end with ? are null propagating or "database" operators, and will return null if either operand is null. They short-circuit differently than normal operators (only if the left operand is null).
<syntaxhighlight lang="langur">val .test =
join("\n", [
"{{.a}} nxor {{.b}}: {{.a nxor .b}}",
"",
"{{.a}} nxor? {{.b}}: {{.a nxor? .b}}",
"\n",
])
}
val .tests = [
Line 4,278 ⟶ 4,283:
However, it does support the short-circuiting ''&&'' and ''||'' logical operators as well as the conditional (or ternary) operator ''?:'' all of which behave as expected.
<syntaxhighlight lang="
System.print("a = %(a)")
System.print("b = %(b)")
|