3 ms·
> 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 parti
by LandR 6y ago
> 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 the others. My next most common would be piping it into arbitrary locations, e.g.:
; pipe into an arbitrary spot (specified here as o)
(as-> (range 1 10) o
(map inc o)
(filter even? o)
(reduce + o))
I rarely use thread-first.
- grantjpowell 6y agoElixir has an anonymous function short hand that makes the "partial application" use case pretty easy for me. &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