Does clojure implement left fold or right fold?
I understand there is a new library reducers which has this but shouldn't it exists in clojure.core?
As Thumbnail points out, reduce-right cannot be efficiently implemented on the jvm for sequences. But as it turns out, we do have a family of data types that can do efficient lookup and truncation from the right side. reduce-right can be implemented for vectors.
user>
(defn reduce-right
[f init vec]
(loop [acc init v vec]
(if (empty? v)
acc
(recur (f acc (peek v)) (pop v)))))
#'user/reduce-right
user> (count (str (reduce-right *' 1 (into [] (range 1 100000))))) ; digit count
456569