Skip to content

Instantly share code, notes, and snippets.

@Schockarum
Last active November 11, 2019 18:57
Show Gist options
  • Save Schockarum/ee0e025ccdd6d29b3ac3de9283030863 to your computer and use it in GitHub Desktop.
Save Schockarum/ee0e025ccdd6d29b3ac3de9283030863 to your computer and use it in GitHub Desktop.
Programming Elixir 1.2 Book - Exercise 1: Functions
#Go into iex. Create and run the functions that do the following:
# list_concat.([:a, :b], [:c, :d]) #=> [:a, :b, :c, :d]
# sum.(1, 2, 3) #=> 6
# pair_tuple_to_list.( { 1234, 5678 } ) #=> [ 1234, 5678 ]
defmodule Exercise1 do
#list_concat = fn a,b -> a ++ b end
def list_concat(a,b) do
a ++ b
end
#sum = fn a, b, c -> a + b + c end
def sum(a,b,c) do
a + b + c
end
#pair_tuple_to_list = fn {a, b} -> [a, b]
def pair_tuple_to_list({a,b}) do
[a,b]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment