Skip to content

Instantly share code, notes, and snippets.

@ronaldofs
Created June 28, 2017 15:31
Show Gist options
  • Select an option

  • Save ronaldofs/ed3dc38f658e408fb723f84db9485d12 to your computer and use it in GitHub Desktop.

Select an option

Save ronaldofs/ed3dc38f658e408fb723f84db9485d12 to your computer and use it in GitHub Desktop.
Flatten lists
defmodule Flattener do
def flatten([head|tail]), do: flatten(head) ++ flatten(tail)
def flatten([]), do: []
def flatten(value), do: [value]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment