user=> (defmulti length empty?)
#'user/length

user=> (defmethod length true [x] 0)
#<MultiFn clojure.lang.mult...@1807ca8>

user=> (defmethod length false [x] (+ 1 (length (rest x))))
#<MultiFn clojure.lang.mult...@1807ca8>

user=> (length [1 2 3 4])
4


On Fri, Aug 21, 2009 at 12:41 PM, Michel
Salim<michael.silva...@gmail.com> wrote:
>
> On Fri, 2009-08-21 at 11:02 -0700, Sigrid wrote:
>> Hi,
>>
>> I read the related story on InfoQ and found it an extremely
>> interesting and motivating read, Clojure being applied in such an
>> interesting field as machine learning!
>>
>> There is something in the article I'd like to understand better, so
>> i'm just asking here on the group:
>>
>> "The way that Rich elected to de-couple destructuring bind from
>> pattern matching was brilliant."
>>
>> Could someone point me to what the difference is? I know pattern
>> matching e.g. from the PLT scheme implementation, and there the
>> pattern matching also provides the binding and destructuring I
>> think...?
>>
> Clojure allows destructuring of vectors, which happens to be what its
> functions' argument lists are, so you get most of the benefits of
> pattern matching. It's not full-blown, though, so (correct me if I'm
> wrong) the equivalent of this is not possible:
>
> length [] = 0
> length (_:xs) = 1 + (length xs)
>
> Regards,
>
> --
> Michel
>
>
> >
>



-- 
And what is good, Phaedrus,
And what is not good—
Need we ask anyone to tell us these things?

--~--~---------~--~----~------------~-------~--~----~
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
Note that posts from new members are moderated - please be patient with your 
first post.
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to