Skip to content

Instantly share code, notes, and snippets.

@iporsut
Created May 10, 2015 13:20
Show Gist options
  • Select an option

  • Save iporsut/1431e03f826d9e8ee788 to your computer and use it in GitHub Desktop.

Select an option

Save iporsut/1431e03f826d9e8ee788 to your computer and use it in GitHub Desktop.
mylist flatten
-module(mylist).
-export([flatten/1]).
flatten(L) -> flatten(L, []).
flatten([], Acc) -> Acc;
flatten([H|T], Acc) when is_list(H) -> flatten(T, Acc ++ flatten(H));
flatten([H|T], Acc) -> flatten(T, Acc ++ [H]).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment