diff --git a/maps/myenum.exs b/maps/myenum.exs index 2cbd775..e6955cb 100644 --- a/maps/myenum.exs +++ b/maps/myenum.exs @@ -45,6 +45,23 @@ defmodule MyEnum do end end + # I gave up on these two. # split # take end + +defmodule MyList do + def flatten([]) do + [] + end + + def flatten([head|tail]) do + # this is basically the recursion + flatten(head) ++ flatten(tail) + end + + def flatten(head) do + # if there's only on element, we make a list out of it, so that we can concat them + [head] + end +end