Jump to content

Logical operations: Difference between revisions

(PascalABC.NET)
 
Line 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 = fn(.a, .b) {
val test = fn(a, b) {
join("\n", [
"not {{.a}}: {{not .a}}",
"{{.a}} and {{.b}}: {{.a and .b}}",
"{{.a}} nand {{.b}}: {{.a nand .b}}",
"{{.a}} or {{.b}}: {{.a or .b}}",
"{{.a}} nor {{.b}}: {{.a nor .b}}",
"{{.a}} xor {{.b}}: {{.a xor .b}}",
"{{.a}} nxor {{.b}}: {{.a nxor .b}}",
"",
"not? {{.a}}: {{not? .a}}",
"{{.a}} and? {{.b}}: {{.a and? .b}}",
"{{.a}} nand? {{.b}}: {{.a nand? .b}}",
"{{.a}} or? {{.b}}: {{.a or? .b}}",
"{{.a}} nor? {{.b}}: {{.a nor? .b}}",
"{{.a}} xor? {{.b}}: {{.a xor? .b}}",
"{{.a}} nxor? {{.b}}: {{.a nxor? .b}}",
"\n",
])
}
 
val .tests = [
[true, false],
[false, true],
Line 2,286 ⟶ 2,287:
]
 
for .t in .tests {
write .test(.t[1], .t[2])
}
}</syntaxhighlight>
 
{{out}}
1,007

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.