30 lines
930 B
Plaintext
30 lines
930 B
Plaintext
total(values: List<Decimal>) (answer: Decimal) {
|
|
answer = sum(values)
|
|
}
|
|
|
|
verify() (answer: Bool) {
|
|
answer = total([]) == 0.0 and total([0.1, 0.2, -0.05]) == 0.25
|
|
}
|
|
|
|
add(left: Decimal, right: Decimal) (answer: Decimal) { answer = left + right }
|
|
|
|
subtract(left: Decimal, right: Decimal) (answer: Decimal) { answer = left - right }
|
|
|
|
multiply(left: Decimal, right: Decimal) (answer: Decimal) { answer = left * right }
|
|
|
|
divide(left: Decimal, right: Decimal) (answer: Decimal) { answer = left / right }
|
|
|
|
calculate(left: Decimal, right: Decimal) (answer: Decimal) {
|
|
answer = (left * right + left) / right - left
|
|
}
|
|
|
|
scale(value: Decimal) (answer: Decimal) { answer = value * 2 }
|
|
|
|
scaled(values: List<Decimal>) (answer: Decimal) { answer = sum(scale, values) }
|
|
|
|
convert(value: Int) (answer: Decimal) { answer = value }
|
|
|
|
constants() (answer: List<Decimal>) {
|
|
answer = [-0, -0.00, -9223372036854775808, 9223372036854775807, 1 + 2]
|
|
}
|