by baconmania · 10y ago · 0 comments
What's certain is that it's disingenuous to say that you have to explain those concepts in other languages, but not in Clojure. You might even say that you can guess what `zipped` and `sum` do, but the Clojure example really gives you no information about what's happening behind the scenes.
Learning "about" the variadicity of what are, in other languages, binary infix operations, is certainly a thing to learn, but it's a different kind of thing to learn than learning about "zipped" or "map". It's more of a "changing the way you think" kind of thing than a "knowing what tool to use" kind of thing. Like learning about destructuring pattern-matching, or actor-modelled crash-only software.
"I would say that map being variadic on the set-of-things-being-mapped, and + being variadic on the set-of-things-to-add, is more of a "semantic axiom of the language" than plain-old DSL-esque "magic."
When you debate about any LISP based language is usually my clue.
I respectfully disagree. Map is almost a universal function and IMO, anyone who knows about map will instantly grok what the Clojure version does. The reason this looks so simple in Clojure is due to the fact that the map function is variadic (as our most other functions in Clj) but that is clearly not magic for any experienced programmer.
According to Wikipedia `map` is also variadic in in D, in J, in Mathematica, in Prolog (and logtalk), in Python and in R (to an extent, `lapply` is not variadic but `mapply` can take 2+ sequences).
Variadic map is by no means limited to lisps.
Either way, I seem to remember that Clojure does have a REPL function to show you the source code for any function. You can use that to know what's going on behind the scenes.