News for hackers. Stuff that matters.
Re:Reducers, transducers and core.async in Clojure by WaxProlix on Wednesday June 07, 2017 @02:22PM (#14508674)
Possibly stupid question:

At the top of the article, we see `(reduce + (map inc (filter even? s)))` -- here, `reduce` is a two-place predicate, taking a function and a collection.

Later, `reduce` is taking a function, a 'base case' [], and a collection -- it's a three-place predicate, more in line with a signature for `fold` than what I'm used to seeing for `reduce`.

Is this a clojure specific overload thing? I'm not at all an expert in FP or anything so it might be fairly standard.

Re:Reducers, transducers and core.async in Clojure by eliben on Wednesday June 07, 2017 @03:39PM (#14509283)
Take a look at https://github.com/clojure/clojure/blob/master/src/clj/cloju...

TL;DR: Clojure supports multi-arity functions (sort of like operator overloading in C++, but overloading for the number of operands, not their types)

When no default value is given, the result of reduce on the first two elements is used.

Re:Reducers, transducers and core.async in Clojure by dragonwriter on Wednesday June 07, 2017 @02:31PM (#14508735)
It's fairly common in functional programming languages for functions to be differentiated both by name and arity (reduce/2 being different from reduce/3.)
Re:Reducers, transducers and core.async in Clojure by WaxProlix on Wednesday June 07, 2017 @05:42PM (#14510096)
I feel like this is fairly opposed to things like partial application and currying in general, no?
Re:Reducers, transducers and core.async in Clojure by dragonwriter on Wednesday June 07, 2017 @07:00PM (#14510529)
It has implications for the viable syntaxes for partial application and currying, but is not opposed to it.

For instance, you could use a distinct sigil for an omitted argument for partial application.

Re:Reducers, transducers and core.async in Clojure by WaxProlix on Wednesday June 07, 2017 @10:27PM (#14511435)
Good point, thanks.