Hi, Stu, Loving your book!
I posted a reply earlier, through a different interface, which went to "moderators". Sorry for the clumsiness, but I'm not familiar with the mechanics of newsgroups. On Sep 11, 7:28 am, Stuart Halloway <[email protected]> wrote: > The consing version of ev-stream is self-referential, because you explicitly > made it so by consing it back onto itself. So it only has two items in it, > though it bounces back and forth between them forever. The cycling version is > not self-referential. Since it's the self reference that gives the nice results (finite memory consumption, and apparently better speed), I came up with a little macro to provide it: (defmacro defcycle [name coll] `(def ~name (lazy-seq (concat ~coll ~name))) ) This is probably not the most useful way to do it, since the user has to provide name. > > Now I'll test it with 9876543210, a number which "ev?" was able to > > handle: > > > user=> (time (mod3 9876543210)) > > "Elapsed time: 37759.615 msecs" > > 1 > > user=> (mod 987654321 3) > > 0 > > > Whoa! The computation finished in reasonable time, but with the WRONG > > answer! How did that happen? > > Did I find a bug? > > No, there is simply a typo in your input arg. with the typo fixed, i.e. (mod 9876543210 3), the result is still 0. regards, George -- 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
