Earlier quoted context omitted.
An Elixir convention I've seen is to put the thing you're operating on first, so that you can compose functions using the `|>` operator, which places the previous expression as the first argument of the function to the right. Maybe something like this? defmodule Compare do def clamp(number, minimum, maximum) do number |> max(minimum) |> min(maximum) end end import Compare clamp(5, 1, 10) # 5 clamp(1, 5, 10) # 5 clamp…
> It makes the most "important" argument of the function the first thing you read in function signatures Doesn't that make writing functions that can use partial application harder? e.g. If I was writing clamp i would want the signature to be (defn clamp [min max n] ,,,) Then I can do: (map (partial clamp 1 11) [-14 2 5 8 11 15 18]) I know when I use Clojures threading macros I use thread last way more than any of th…
&Compare.clamp(&1, some_min, some_max)
The above creates an arity one function which puts the arg into the first position in the original function.I've never felt pain around partial application because I use the anonymous function short hand a good deal