Data update
This commit is contained in:
parent
81fd053722
commit
52a6ef48dd
10248 changed files with 63654 additions and 6775 deletions
|
|
@ -2,28 +2,26 @@
|
|||
|its interface can be easily emulated as shown below.
|
||||
|The performace is worse than using / and % operators.
|
||||
|^
|
||||
fun divmod = Pair by int dividend, int divisor
|
||||
Pair result = int%int().named("quotient", "remainder")
|
||||
result.quotient = dividend / divisor
|
||||
result.remainder = dividend % divisor
|
||||
return result
|
||||
end
|
||||
fun main = int by List args
|
||||
fun divmod ← <int dividend, int divisor|int%int(dividend / divisor ⇒
|
||||
dividend % divisor).named("quotient", "remainder")
|
||||
fun main ← int by List args
|
||||
int a, b
|
||||
if args.length == 2
|
||||
a = int!args[0]
|
||||
b = int!args[1]
|
||||
if args.length æ 2
|
||||
a ← int!args[0]
|
||||
b ← int!args[1]
|
||||
else
|
||||
a = ask(int, "first number: ")
|
||||
b = ask(int, "second number: ")
|
||||
a ← ask(int, "first number: ")
|
||||
b ← ask(int, "second number: ")
|
||||
end
|
||||
writeLine("sum: " + (a + b))
|
||||
writeLine("difference: " + (a - b))
|
||||
writeLine("product: " + (a * b))
|
||||
writeLine("integer quotient: " + (a / b)) # truncates towards 0
|
||||
writeLine("remainder: " + (a % b)) # matches sign of first operand
|
||||
writeLine("exponentiation: " + (a ** b))
|
||||
writeLine("divmod: " + divmod(a, b))
|
||||
writeLine("exponent: " + (a ** b)) # a raised to the power of b
|
||||
writeLine("root: " + (a // b)) # a √ b
|
||||
writeLine("logarithm: " + (a %% b)) # log a (b)
|
||||
return 0
|
||||
end
|
||||
exit main(Runtime.args)
|
||||
|
|
|
|||
2
Task/Arithmetic-Integer/Komodo/arithmetic-integer.komodo
Normal file
2
Task/Arithmetic-Integer/Komodo/arithmetic-integer.komodo
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
let arithmetic(a, b) := (a + b, a - b, a * b, a / b, a % b, a ** b)
|
||||
assert(arithmetic(5, 2) = (7, 3, 10, 2, 1, 25))
|
||||
Loading…
Add table
Add a link
Reference in a new issue