I made some tests, and if I am not mistaken, if an eos is not specifically specified, Object is used, is that right?
user=> (let [iter (stream-iter (range 5))] (def s (stream (fn [eos] (let [x (next! iter eos)] (if (= eos x) (do (println eos) eos) x)))))) #'user/s user=> (seq s) (0 1 2 3 #<Object java.lang.obj...@25c828> 4) Vincent On Jan 21, 7:59 pm, Rich Hickey <richhic...@gmail.com> wrote: > On Jan 21, 7:40 pm, Vincent Foley <vfo...@gmail.com> wrote: > > > I have a question regarding the examples, specifically map* and > > filter* > > > (defn map* [f coll] > > (let [iter (stream-iter coll)] > > (stream > > (fn [eos] > > (let [x (next! iter eos)] > > (if (= eos x) x (f x))))))) > > > (take 4 (map* inc (filter* even? (range 1000000)))) > > -> (1 3 5 7) > > > How is eos passed to the fn inside stream and what is it? > > The caller provides eos in calls to the (next! iter eos), which in > turn passes it to the generator. The caller should choose a value for > eos that will not be present in the set of items, which can easily be > created by calling (Object.), as is done by reduce*. > > I've enhanced the docs to explain this, and commented the example. > > Rich --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---