How to resolve the algorithm Logical operations step by step in the langur programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Logical operations step by step in the langur programming language
Table of Contents
Problem Statement
Write a function that takes two logical (boolean) values, and outputs the result of "and" and "or" on both arguments as well as "not" on the first arguments. If the programming language doesn't provide a separate type for logical values, use the type most commonly used for that purpose. If the language supports additional logical operations on booleans such as XOR, list them as well.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Logical operations step by step in the langur programming language
Source code in the langur programming language
val .test = f(.a, .b) join("\n", [
$"not \.a;: \{not .a}",
$"\.a; and \.b;: \.a and .b;",
$"\.a; or \.b;: \.a or .b;",
$"\.a; nand \.b;: \.a nand .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; or? \.b;: \.a or? .b;",
$"\.a; nand? \.b;: \.a nand? .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],
[true, true],
[false, false],
# including null...
[true, null],
[null, true],
[false, null],
[null, false],
[null, null],
]
for .t in .tests {
write .test(.t[1], .t[2])
}
You may also check:How to resolve the algorithm Sorting algorithms/Shell sort step by step in the C programming language
You may also check:How to resolve the algorithm Write float arrays to a text file step by step in the SPL programming language
You may also check:How to resolve the algorithm Optional parameters step by step in the Swift programming language
You may also check:How to resolve the algorithm Web scraping step by step in the PicoLisp programming language
You may also check:How to resolve the algorithm Maze generation step by step in the Rust programming language