@fedeotaran
otaran.federico@gmail.com
Pensar soluciones en funcional
Nuevos conceptos:
No querer implementar objetos en Elixir
Process Agent Task GenServer Supervisor
¿Qué proponemos?
Simple   =>
Complejo
El sÃmbolo "=" es el operador match.
iex(1)> x = 2
2
iex(2)> 2 = x
2
iex(3)> 1 = x
** (MatchError) no match of right hand side value: 2
(stdlib) erl_eval.erl:453: :erl_eval.expr/5
(iex) lib/iex/evaluator.ex:257: IEx.Evaluator.handle_eval/5
(iex) lib/iex/evaluator.ex:237: IEx.Evaluator.do_eval/3
(iex) lib/iex/evaluator.ex:215: IEx.Evaluator.eval/3
(iex) lib/iex/evaluator.ex:103: IEx.Evaluator.loop/1
(iex) lib/iex/evaluator.ex:27: IEx.Evaluator.init/4
response = HTTP.patch(url, body, headers, [])
case response do
{:ok, %{status_code: 200, body: body}} ->
body
{:ok, %{status_code: 404} = resp} ->
"Error: #{resp.status_code} Not found!"
{:error, %{reason: reason}} ->
"Error: #{reason}"
end
defmodule Math do
def zero?(0), do: true
def zero?(x) when is_integer(x), do: false
end
defmodule Person do
defstruct [:name, :age]
def hello!(), do: "1) Hola!"
def hello!(%Person{name: person_name}), do: "2) Hola persona!"
def hello!(%{name: "Mirta"} = person) do
"3) Hola Mirta! tenes #{person.age} años"
end
def hello!(%{name: person_name}), do: "4) Hola #{person_name}!"
end
ls | grep "Do"
string = "hello, world!"
words = String.split(string, " ")
capitalized_words = Enum.map(words, &String.capitalize/1)
Enum.join(capitalized_words, " ")
"hello, world!"
|> String.split(" ")
|> Enum.map(&String.capitalize/1)
|> Enum.join
Sin pipeline operator:
Con pipeline operator:
mix new
mix compile
iex -S mix
mix deps.get
mix docs
mix test