Pandy's Blog

Pandy Song

Closure notes

Introduction

The problem in following pages got attention. http://www.4clojure.com/problem/60#prob-title

solution

Here is my solution which passes the unit tests.


(fn myreduce
  ([f coll]
   (when-let [s (seq coll)]
     (myreduce f (first s) (rest s))))
  ([f v coll]
   (lazy-seq (cons v (when-let [s (seq coll)]
                       (myreduce f (f v (first s)) (rest s)))))))