cgrand / xforms

Extra transducers and reducing fns for Clojure(script)
575 stars 32 forks source link

Constantly function #24

Closed ds923y closed 6 years ago

ds923y commented 6 years ago

I did not find a function constantly. It would be convienient if one could be added.

(defn xform-constantly [value]
  (fn [xf]
    (fn ([] (xf))
      ([result] (xf result))
      ([result input] (xf result value)))))
cgrand commented 6 years ago

Well it's either (map (constantly x)) or (x/for [_ %] x) (there are certainly more ways to write it), I don't think there's a strong case for making it a standalone function.

ds923y commented 6 years ago

Yes the case for it was only convenience.