mers/examples/02_Calc_Sum.mers

14 lines
324 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
2024-06-19 13:58:30 +02:00
().read_line.try(
(line) -> line.trim.parse_float.try(
(n) -> &total = (total, n).sum
() -> "Not a number".eprintln
)
// CTRL+D, so return a 1-tuple to break from the loop
2023-10-27 19:19:42 +02:00
() -> (())
2024-03-22 16:50:01 +01:00
)
}
2023-10-19 19:38:13 +02:00
"Goodbye.".println