Working on the Little Elixir and OTP guidebook, and I have a simple question from chapter 3.
question:
The function head of defp compute_temperature(json) do is arity/1
The call to function compute_temperature (see below) is arity/0 (right?) If so, how is compute_temperature(json) arity/1 being called when it looks like it’s arity/0 after it’s passed from JSON.decode! after the pipe operator?
defp parse_response({:ok, %HTTPoison.Response{body: body, status_code: 200}}) do
body |> JSON.decode! |> compute_temperature
end
Might also take a look into partial (function) application (and the linked to Currying) and Thunk.
These three concepts are the building blocks of functional programming (in general).
Technically Erlang and Elixir both lack partial application and currying. You can make a new anonymous function that wraps a function with more calls, but it itself does not have currying. That is one feature that I really wish Elixir added to Erlang. ^.^