by sodapopcan · 5y ago · 0 comments
Clojure is way more consistent in this regard:
- thread first (->) when operating on maps.
- thread last (->>) when operating on sequences.
- as-> "choose your own adventure".The only place where pipe order bristles is Enum.reduce, but I'd bet if I counted I'd have wanted it the normal way more often than the backwards way.
often you want to apply a list of actions to an object.
This is a "backward reduce".
I don't feel it often, but when I do, it's such a bummer.
Clojure also doesn’t have auto currrying, but makes up for it by giving you 6 variants and creating a consistent default library for sequences and associative structures.
So, the pipe first operator is just a dirty hack.
I'm a bit stuck on your Clojure example still, though. If a language doesn't have auto-currying (or even currying at all in Elixir's case), why does the argument order matter? Whether it's a List or a Map, what does it matter if it's passed first instead of last?