Regular functions have this clever ability to have their variadic
arguments applied lazily:

user=> (defn z [a & r] "zero")
#'user/z
user=> (apply z (iterate inc 0))
"zero"

Since the z function ignored the r sequence, apply didn't bother
walking down the infinite sequence at all.

Multimethods don't have this same feature:

user=> (defmulti z (fn [a & r] a))
#'user/z
user=> (defmethod z 0 [a & r] "zero")
[EMAIL PROTECTED]
user=> (z 0)
"zero"
user=> (apply z (take 100 (iterate inc 0)))
"zero"

So good so far -- the r argument works as expected.  But if we give it
an infinite sequence, it gets stuck in an infinite loop:

user=> (apply z (iterate inc 0)) ; never comes back

You have been warned. :-)
--Chouser

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to