lama_byterun/regression/test085.lama

31 lines
446 B
Text
Raw Normal View History

2024-07-01 12:48:21 +02:00
var n;
2020-01-05 03:33:17 +03:00
fun sum (l) {
case l of
{} -> 0
| h : t -> (h + sum (t))
esac
}
fun print_list (l) {
case l of
{} -> skip
| h : t -> write (h); print_list (t)
esac
}
fun array_to_list (a) {
var l, i;
2020-01-05 03:33:17 +03:00
l := {};
for i := a.length, i > 0, i := i-1 do
l := a[i-1] : l
od;
l
}
2024-07-01 12:48:21 +02:00
n := read ();
2020-01-05 03:33:17 +03:00
write (sum ({}));
write (sum ({1, 2, 3, 4, 5}));
write (sum (1:2:3:4:5:{}));
print_list (array_to_list ([1, 2, 3, 4, 5]))