На Scala это выглядит так:
def product(mapFunc: (Int) => Int, reduceFunc: (Int, Int) => Int, r: Range): Int =
r.map(mapFunc).reduceLeft(reduceFunc)
println(product((x) => x * x, (x, y) => x * y, 1 until 5))
На Clojure так:
(defn product [mapFunc reduceFunc r]
(reduce reduceFunc (map mapFunc r)))
(println (product (fn [x] (* x x)) (fn [x y
(
Read more... )