Skip to content

Instantly share code, notes, and snippets.

@meddle0x53
Created February 5, 2018 11:21
Show Gist options
  • Select an option

  • Save meddle0x53/36d0bf3f708fdc6d8f22a4b8fb137016 to your computer and use it in GitHub Desktop.

Select an option

Save meddle0x53/36d0bf3f708fdc6d8f22a4b8fb137016 to your computer and use it in GitHub Desktop.
Simpler flatten
def flatten([head | tail], result) when is_list(head), do: flatten(head, flatten(tail, result))
def flatten([head | tail], result), do: [head | flatten(tail, result)]
def flatten([], result), do: result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment