September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
26
Task/Logical-operations/360-Assembly/logical-operations.360
Normal file
26
Task/Logical-operations/360-Assembly/logical-operations.360
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
* Logical operations 04/04/2017
|
||||
LOGICAL CSECT
|
||||
USING LOGICAL,R15
|
||||
* -- C=A and B
|
||||
MVC C,A C=A
|
||||
NC C,B C=A and B
|
||||
* -- C=A or B
|
||||
MVC C,A C=A
|
||||
OC C,B C=A or B
|
||||
* -- C=not A
|
||||
MVC C,A C=A
|
||||
XI C,X'01' C=not A
|
||||
* -- if C then goto e
|
||||
CLI C,X'01' if C
|
||||
BE E then goto e
|
||||
XPRNT =C'FALSE',5
|
||||
*
|
||||
E BR R14
|
||||
TRUE DC X'01'
|
||||
FALSE DC X'00'
|
||||
A DC X'01'
|
||||
B DC X'00'
|
||||
C DS X
|
||||
PG DC CL80' '
|
||||
YREGS
|
||||
END LOGICAL
|
||||
6
Task/Logical-operations/BASIC/logical-operations-1.basic
Normal file
6
Task/Logical-operations/BASIC/logical-operations-1.basic
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
10 A = -1
|
||||
20 B = 0
|
||||
30 PRINT A AND B
|
||||
40 PRINT A OR B
|
||||
50 PRINT (A AND (NOT B)) OR ((NOT A) AND B)
|
||||
60 PRINT NOT A
|
||||
25
Task/Logical-operations/Bc/logical-operations-1.bc
Normal file
25
Task/Logical-operations/Bc/logical-operations-1.bc
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
/* The following three functions assume 0 is false and 1 is true */
|
||||
|
||||
/* And */
|
||||
define a(x, y) {
|
||||
return(x * y)
|
||||
}
|
||||
|
||||
/* Or */
|
||||
define o(x, y) {
|
||||
return(x + y - x * y)
|
||||
}
|
||||
|
||||
/* Not */
|
||||
define n(x) {
|
||||
return(1 - x)
|
||||
}
|
||||
|
||||
define f(a, b) {
|
||||
"a and b: "
|
||||
a(a, b)
|
||||
"a or b: "
|
||||
o(a, b)
|
||||
"not a: "
|
||||
n(a)
|
||||
}
|
||||
5
Task/Logical-operations/Bc/logical-operations-2.bc
Normal file
5
Task/Logical-operations/Bc/logical-operations-2.bc
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
define logic_test(a, b) {
|
||||
print "a and b: ", a && b, "\n"
|
||||
print "a or b: ", a || b, "\n"
|
||||
print "not a: ", !a, "\n"
|
||||
}
|
||||
16
Task/Logical-operations/Elm/logical-operations.elm
Normal file
16
Task/Logical-operations/Elm/logical-operations.elm
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
--Open cmd and elm-repl and directly functions can be created
|
||||
|
||||
--Creating Functions
|
||||
t=True
|
||||
f=False
|
||||
opand a b= a && b
|
||||
opor a b= a || b
|
||||
opnot a= not a
|
||||
|
||||
--Using the created Functions
|
||||
opand t f
|
||||
opor t f
|
||||
opnot f
|
||||
|
||||
--Output will be False, True and True of type Boolean!
|
||||
--end
|
||||
1
Task/Logical-operations/Gecho/logical-operations-1.gecho
Normal file
1
Task/Logical-operations/Gecho/logical-operations-1.gecho
Normal file
|
|
@ -0,0 +1 @@
|
|||
3 4 and
|
||||
1
Task/Logical-operations/Gecho/logical-operations-2.gecho
Normal file
1
Task/Logical-operations/Gecho/logical-operations-2.gecho
Normal file
|
|
@ -0,0 +1 @@
|
|||
1 2 or
|
||||
4
Task/Logical-operations/Hy/logical-operations.hy
Normal file
4
Task/Logical-operations/Hy/logical-operations.hy
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
(defn logic [a b]
|
||||
(print "a and b:" (and a b))
|
||||
(print "a or b:" (or a b))
|
||||
(print "not a:" (not a)))
|
||||
20
Task/Logical-operations/Kotlin/logical-operations.kotlin
Normal file
20
Task/Logical-operations/Kotlin/logical-operations.kotlin
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
// version 1.0.6
|
||||
|
||||
fun logicalDemo(b1: Boolean, b2: Boolean) {
|
||||
println("b1 = $b1")
|
||||
println("b2 = $b2")
|
||||
println("b1 and b2 = ${b1 and b2}")
|
||||
println("b1 or b2 = ${b1 or b2}")
|
||||
println("b1 xor b2 = ${b1 xor b2}")
|
||||
println("not b1 = ${!b1}")
|
||||
println("b1 && b2 = ${b1 && b2}")
|
||||
println("b1 || b2 = ${b1 || b2}")
|
||||
println()
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
logicalDemo(true, true)
|
||||
logicalDemo(true, false)
|
||||
logicalDemo(false, false)
|
||||
logicalDemo(false, true)
|
||||
}
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
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);
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
3 && 10 is 10
|
||||
3 || 10 is 3
|
||||
3 ^^ 10 is
|
||||
!3 is 0
|
||||
3 ?& 10 is 1
|
||||
3 ?| 10 is 1
|
||||
3 ?^ 10 is 0
|
||||
3 +& 10 is 2
|
||||
3 +| 10 is 11
|
||||
3 +^ 10 is 9
|
||||
3 ~& 10 is 1
|
||||
3 ~| 10 is 30
|
||||
3 ~^ 10 is 30
|
||||
3 & 10 is all(3, 10)
|
||||
3 | 10 is any(3, 10)
|
||||
3 ^ 10 is one(3, 10)
|
||||
3 and 10 is 10
|
||||
3 or 10 is 3
|
||||
3 xor 10 is
|
||||
not 3 is 0
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
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,8 +0,0 @@
|
|||
rascal>logic(false, false);
|
||||
|
||||
a and b, is false
|
||||
a or b, is false
|
||||
a equivalent to b, is true
|
||||
a implies b, is true
|
||||
not a, true
|
||||
ok
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
{#/\. #\/. #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]]
|
||||
|
||||
].
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
True/\True = True
|
||||
True/\False = False
|
||||
False/\True = False
|
||||
False/\False = False
|
||||
True\/True = True
|
||||
True\/False = True
|
||||
False\/True = True
|
||||
False\/False = False
|
||||
True not = False
|
||||
False not = True
|
||||
3
Task/Logical-operations/Zkl/logical-operations.zkl
Normal file
3
Task/Logical-operations/Zkl/logical-operations.zkl
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
fcn f(a,b){a and b}
|
||||
fcn g(a,b){a or b}
|
||||
fcn h(a){(not a)}
|
||||
Loading…
Add table
Add a link
Reference in a new issue