lama_byterun/regression/test051.expr

32 lines
469 B
Text
Raw Normal View History

2019-09-29 02:47:07 +03:00
local n;
2019-03-07 21:12:43 +03:00
fun sum (l) {
case l of
{} -> return 0
| h : t -> return (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) {
local l, i;
2019-03-07 21:12:43 +03:00
l := {};
for i := a.length, i > 0, i := i-1 do
l := a[i-1] : l
od;
return l
}
n := read ();
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]))