Skip to content

Instantly share code, notes, and snippets.

@kevinkirkup
Created February 10, 2021 16:16
Show Gist options
  • Save kevinkirkup/6c7ee3b1c00eeeb5348aea9c7e5f5bda to your computer and use it in GitHub Desktop.
Save kevinkirkup/6c7ee3b1c00eeeb5348aea9c7e5f5bda to your computer and use it in GitHub Desktop.
defmodule HW1 do
def flatten([]), do: []
def flatten([head | []]), do: [head]
def flatten([[head] | [tail]]), do: [head | flatten(tail)]
def flatten([head | [tail]]), do: [head | flatten(tail)]
def flatten([head | tail]), do: [head | flatten(tail)]
def flatten(head), do: [head]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment