Put flat_map in ListInternal.aes

This commit is contained in:
Ulf Norell
2019-08-27 11:33:43 +02:00
parent 02af75aa34
commit e7d3a5b9f2
2 changed files with 7 additions and 9 deletions
+5 -5
View File
@@ -1,9 +1,9 @@
namespace ListInternal =
private function reverse_(xs : list('a), ys : list('a)) : list('a) =
// -- Flatmap ----------------------------------------------------------------
function flat_map(f : 'a => list('b), xs : list('a)) : list('b) =
switch(xs)
[] => ys
x :: xs => reverse_(xs, x :: ys)
function reverse(xs : list('a)) = reverse_(xs, [])
[] => []
x :: xs => f(x) ++ flat_map(f, xs)