Just another update
This commit is contained in:
parent
a25938f123
commit
00a190b0a6
6591 changed files with 94363 additions and 23227 deletions
|
|
@ -1,3 +1,5 @@
|
|||
{{basic data operation}}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.
|
||||
{{basic data operation}} [[Category:Simple]]
|
||||
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.
|
||||
|
|
|
|||
1
Task/Logical-operations/Excel/logical-operations-1.excel
Normal file
1
Task/Logical-operations/Excel/logical-operations-1.excel
Normal file
|
|
@ -0,0 +1 @@
|
|||
=CONCATENATE($A1, " AND ", $B1, " is ", AND($A1,$B1))
|
||||
1
Task/Logical-operations/Excel/logical-operations-2.excel
Normal file
1
Task/Logical-operations/Excel/logical-operations-2.excel
Normal file
|
|
@ -0,0 +1 @@
|
|||
=CONCATENATE($A1, " OR ", $B1, " is ", OR($A1,$B1))
|
||||
1
Task/Logical-operations/Excel/logical-operations-3.excel
Normal file
1
Task/Logical-operations/Excel/logical-operations-3.excel
Normal file
|
|
@ -0,0 +1 @@
|
|||
=CONCATENATE(" NOT ", $A1, " is ", NOT($A1))
|
||||
14
Task/Logical-operations/OOC/logical-operations.ooc
Normal file
14
Task/Logical-operations/OOC/logical-operations.ooc
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
logic: func (a: Bool, b: Bool) {
|
||||
println()
|
||||
"A=#{a}, B=#{b}:" println()
|
||||
"AND: #{a && b}" println()
|
||||
"OR: #{a || b}" println()
|
||||
"NOT A: #{!a}" println()
|
||||
}
|
||||
|
||||
main: func {
|
||||
logic(true, false)
|
||||
logic(true, true)
|
||||
logic(false, false)
|
||||
logic(false, true)
|
||||
}
|
||||
29
Task/Logical-operations/Perl-6/logical-operations.pl6
Normal file
29
Task/Logical-operations/Perl-6/logical-operations.pl6
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
sub logic($a,$b) {
|
||||
say "$a && $b is ", $a && $b; # short-circuiting
|
||||
say "$a || $b is ", $a || $b; # short-circuiting
|
||||
say "$a ^^ $b is ", $a ^^ $b;
|
||||
say "!$a is ", !$a;
|
||||
|
||||
say "$a ?& $b is ", $a ?& $b; # non-short-circuiting
|
||||
say "$a ?| $b is ", $a ?| $b; # non-short-circuiting
|
||||
say "$a ?^ $b is ", $a ?^ $b; # non-short-circuiting
|
||||
|
||||
say "$a +& $b is ", $a +& $b; # numeric bitwise
|
||||
say "$a +| $b is ", $a +| $b; # numeric bitwise
|
||||
say "$a +^ $b is ", $a +^ $b; # numeric bitwise
|
||||
|
||||
say "$a ~& $b is ", $a ~& $b; # buffer bitwise
|
||||
say "$a ~| $b is ", $a ~| $b; # buffer bitwise
|
||||
say "$a ~^ $b is ", $a ~| $b; # buffer bitwise
|
||||
|
||||
say "$a & $b is ", $a & $b; # junctional/autothreading
|
||||
say "$a | $b is ", $a | $b; # junctional/autothreading
|
||||
say "$a ^ $b is ", $a ^ $b; # junctional/autothreading
|
||||
|
||||
say "$a and $b is ", ($a and $b); # loose short-circuiting
|
||||
say "$a or $b is ", ($a or $b); # loose short-circuiting
|
||||
say "$a xor $b is ", ($a xor $b);
|
||||
say "not $a is ", (not $a);
|
||||
}
|
||||
|
||||
logic(3,10);
|
||||
9
Task/Logical-operations/Rascal/logical-operations.rascal
Normal file
9
Task/Logical-operations/Rascal/logical-operations.rascal
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
import IO;
|
||||
|
||||
public void logic(bool a, bool b){
|
||||
println("a and b, is <a && b>");
|
||||
println("a or b, is <a || b>");
|
||||
println("a equivalent to b, is <a <==> b>");
|
||||
println("a implies b, is <a ==> b>");
|
||||
println("not a", <!a>");
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
def logic(a, b)
|
||||
print 'a and b: ', a && b, "\n"
|
||||
print 'a or b: ' , a || b, "\n"
|
||||
print 'not a: ' , !a , "\n"
|
||||
print 'a and b: ', a && b, "\n"
|
||||
print 'a or b: ' , a || b, "\n"
|
||||
print 'not a: ' , !a , "\n"
|
||||
print 'a xor b: ' , a ^ b, "\n"
|
||||
end
|
||||
|
|
|
|||
9
Task/Logical-operations/Slate/logical-operations.slate
Normal file
9
Task/Logical-operations/Slate/logical-operations.slate
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
{#/\. #\/. #not} do: [ |:func|
|
||||
func arity = 1 ifTrue: [inform: 'True ' ; (func as: String) ; ' = ' ; (func sendTo: {True}) printString.
|
||||
inform: 'False ' ; (func as: String) ; ' = ' ; (func sendTo: {False}) printString.].
|
||||
|
||||
func arity = 2
|
||||
ifTrue: [{{True. True}. {True. False}. {False. True}. {False. False}} do:
|
||||
[ |:each| inform: each first printString ; (func as: String) ; each second printString ; ' = ' ; (func sendTo: each) printString]]
|
||||
|
||||
].
|
||||
Loading…
Add table
Add a link
Reference in a new issue