Created
May 10, 2015 13:20
-
-
Save iporsut/1431e03f826d9e8ee788 to your computer and use it in GitHub Desktop.
mylist flatten
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -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