clojure

roklenarcic 2026-03-30T13:33:45.619769Z

If there a reason why transducer functions are always a function? I mean this kind:

(defn no-arg-transducer []
  (fn [rf] ...
     (fn ([]
Why isn’t this def instead of defn, seems like there is no state there outside the outer (fn [rf]…?

dpsutton 2026-03-30T13:35:28.067629Z

(source cat) shows an example along your thinking.

dpsutton 2026-03-30T13:35:58.041349Z

it’s a function but it takes the rf

roklenarcic 2026-03-30T13:36:30.996859Z

Hm I don’t quite understand what’s the deal with preserving-reduced function there

roklenarcic 2026-03-30T13:37:23.739109Z

oh it double wraps it

☝️ 1
exitsandman 2026-03-30T13:40:07.352169Z

Most such cases are transducer arities for reduction functions (e.g. distinct)

roklenarcic 2026-03-30T13:41:36.868379Z

I see it now, thanks