Implement [a..b]

This commit is contained in:
Ulf Norell
2019-08-27 13:56:39 +02:00
parent 79a928e530
commit 5f733e01dd
5 changed files with 22 additions and 2 deletions
+7
View File
@@ -7,3 +7,10 @@ namespace ListInternal =
[] => []
x :: xs => f(x) ++ flat_map(f, xs)
// -- From..to ---------------------------------------------------------------
function from_to(a : int, b : int) : list(int) = from_to_(a, b, [])
private function from_to_(a, b, acc) =
if (a > b) acc else from_to_(a, b - 1, b :: acc)