How to resolve the algorithm Logical operations step by step in the Smalltalk programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Logical operations step by step in the Smalltalk 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 Smalltalk programming language
Source code in the smalltalk programming language
|test|
test := [ :a :b |
('%1 %2 %3 = %4' % { a. 'and'. b. (a & b) }) displayNl.
('%1 %2 %3 = %4' % { a. 'or'. b. (a | b) }) displayNl.
('%1 %2 = %3' % {'not'. a. (a not) }) displayNl
].
test value: true value: true.
test value: false value: false.
test value: true value: false.
test value: false value: true.
a implies: b
a xor: b
You may also check:How to resolve the algorithm Symmetric difference step by step in the Arturo programming language
You may also check:How to resolve the algorithm Mastermind step by step in the REXX programming language
You may also check:How to resolve the algorithm Menu step by step in the Nim programming language
You may also check:How to resolve the algorithm Square-free integers step by step in the Go programming language
You may also check:How to resolve the algorithm Permutations/Rank of a permutation step by step in the Ruby programming language