Put flat_map in ListInternal.aes
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user