Hello caffe and Yang Dong. Here is my fold-right.
(defn fold-right [f s coll] ((reduce (fn [acc x] #(acc (f x %))) identity coll) s)) ; (fold-right - 1 '(3 1 4)) ; -> ((fn [y3] ; ((fn [y2] ; ((fn [y1] (identity (- 3 y1))) ; (- 1 y2))) ; (- 4 y3))) ; 1) ; -> (- 3 (- 1 (- 4 1))) ; -> 5 ; (fold-right #(concat %2 (list %)) '() '(:a :b :c :d)) ; -> (:d :c :b :a) https://gist.github.com/2893987 https://algobit.atlassian.net/wiki/display/PL/Comparison 2010年11月6日土曜日 11時03分20秒 UTC+9 Yang Dong: > > Maybe because Clojure has a vector, and conj conjoins new elements to > the end of the vector, so there's mere little use of fold-right. But, > fold-right is an abstraction tool, missing it in the core is kind of > pity. > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to [email protected] Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/clojure?hl=en
