Created
February 24, 2016 00:59
-
-
Save s3itz/913914e4348f9445f37e to your computer and use it in GitHub Desktop.
This file contains 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
defmodule Swapper do | |
def swap([]), do: [] | |
def swap([a,b | tail]), do: [b, a | swap(tail)] | |
def swap([_]), do: raise "Can't swap a list with an odd number of elements" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment