Skip to content

Instantly share code, notes, and snippets.

@mattsoutherden
Created September 16, 2014 15:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattsoutherden/322191e950f15799e46f to your computer and use it in GitHub Desktop.
Save mattsoutherden/322191e950f15799e46f to your computer and use it in GitHub Desktop.
def foo([head | *something*]) when head * 2 < *last* do
some return value
end
@cloud8421
Copy link

You could do something like:

def foo([]), do: nil #or what needs to happen
def foo([_h]), do: nil #or what needs to happen
def foo([head | tail]), do: foo(head * 2, List.last(tail))
def foo(head, last) when head < last, do: true #or something else
def foo(head, last), do: false

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment