mers/examples/02_Calc_Sum.mers

11 lines
273 B
Plaintext
Raw Normal View History

2023-10-19 19:38:13 +02:00
total := 0.0
().loop(() -> {
2023-10-19 19:38:13 +02:00
("Total: ", total, ". Type a number to change.").concat.println
2023-10-27 19:19:42 +02:00
().read_line.trim.parse_float.try((
n -> &total = (total, n).sum,
// not a number, so return a 1-tuple to break from the loop
() -> (())
))
})
2023-10-19 19:38:13 +02:00
"Goodbye.".println