Another update from ingydotnet^djgoku
This commit is contained in:
parent
91df62d461
commit
948b86eafa
7604 changed files with 108452 additions and 22726 deletions
14
Task/Logical-operations/ALGOL-W/logical-operations.alg
Normal file
14
Task/Logical-operations/ALGOL-W/logical-operations.alg
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
procedure booleanOperations( logical value a, b ) ;
|
||||
begin
|
||||
|
||||
% algol W has the usual "and", "or" and "not" operators %
|
||||
write( a, " and ", b, ": ", a and b );
|
||||
write( a, " or ", b, ": ", a or b );
|
||||
write( " not ", a, ": ", not a );
|
||||
|
||||
% logical values can be compared with the = and not = operators %
|
||||
% a not = b can be used for a xor b %
|
||||
write( a, " xor ", b, ": ", a not = b );
|
||||
write( a, " equ ", b, ": ", a = b );
|
||||
|
||||
end booleanOperations ;
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
iex(1)> true and false
|
||||
false
|
||||
iex(2)> false or true
|
||||
true
|
||||
iex(3)> not false
|
||||
true
|
||||
14
Task/Logical-operations/Elixir/logical-operations-2.elixir
Normal file
14
Task/Logical-operations/Elixir/logical-operations-2.elixir
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
(28)> nil || 23
|
||||
23
|
||||
iex(29)> [] || false
|
||||
[]
|
||||
iex(30)> nil && true
|
||||
nil
|
||||
iex(31)> 0 && 15
|
||||
15
|
||||
iex(32)> ! true
|
||||
false
|
||||
iex(33)> ! nil
|
||||
true
|
||||
iex(34)> ! 3.14
|
||||
false
|
||||
14
Task/Logical-operations/Julia/logical-operations.julia
Normal file
14
Task/Logical-operations/Julia/logical-operations.julia
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
function exerciselogic(a::Bool, b::Bool)
|
||||
st = @sprintf " %5s" a
|
||||
st *= @sprintf " %5s" b
|
||||
st *= @sprintf " %5s" ~a
|
||||
st *= @sprintf " %5s" a | b
|
||||
st *= @sprintf " %5s" a & b
|
||||
st *= @sprintf " %5s" a $ b
|
||||
end
|
||||
|
||||
println("Julia's logical operations on Bool:")
|
||||
println(" a b not or and xor")
|
||||
for a in [true, false], b in [true, false]
|
||||
println(exerciselogic(a, b))
|
||||
end
|
||||
13
Task/Logical-operations/Rust/logical-operations.rust
Normal file
13
Task/Logical-operations/Rust/logical-operations.rust
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
fn boolean_ops(a: bool, b: bool) {
|
||||
println!("{} and {} -> {}", a, b, a && b);
|
||||
println!("{} or {} -> {}", a, b, a || b);
|
||||
println!("{} xor {} -> {}", a, b, a ^ b);
|
||||
println!("not {} -> {}\n", a, !a);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
boolean_ops(true, true);
|
||||
boolean_ops(true, false);
|
||||
boolean_ops(false, true);
|
||||
boolean_ops(false, false)
|
||||
}
|
||||
4
Task/Logical-operations/Self/logical-operations.self
Normal file
4
Task/Logical-operations/Self/logical-operations.self
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
true not = false.
|
||||
( true && false ) = false.
|
||||
( true ^^ false ) = true. "xor"
|
||||
( true || false ) = true. "or"
|
||||
Loading…
Add table
Add a link
Reference in a new issue