Last active
November 11, 2019 18:57
-
-
Save Schockarum/ee0e025ccdd6d29b3ac3de9283030863 to your computer and use it in GitHub Desktop.
Programming Elixir 1.2 Book - Exercise 1: Functions
This file contains hidden or 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
#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