Mark Engelberg <[email protected]> writes:

> filter works just as well with a function that returns true and false,
> so that's not a particularly good example.

Calling the set as if it is a fn is a short-hand for "get", that is
retrieving an element from the set. Why would you want to do this, when
to look it up you need to know what element is?  Sets are based on
value-equality not reference-equality.  Thus you can have an object in
the set that is equal to your lookup key but not identical.  A simple
example is anything with metadata attached:

(def myset #{(with-meta 'foo {:something 1})})

Now I know what the symbol is but I want to retrieve the metadata from
the version that's in the set:

(meta (myset 'foo))
;;-> {:something 1}

Another use would interning -- returning a canonical version of an
object.

Cheers,

Alex

-- 
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

To unsubscribe, reply using "remove me" as the subject.

Reply via email to