On 2010 Apr 30, at 7:33 AM, Rich Hickey wrote:
> People don't consider sets, vectors, arrays or strings to have
'keys'.
That is not consistent with the documentation:
Sets: http://clojure.org/data_structures:
Sets support 'removal' with disj, as well as contains? and get, the
latter returning the object that is held in the set which compares
equal to the key, if found ...
http://richhickey.github.com/clojure/clojure.core-api.html:
hash-set ... (hash-set & keys) ... Returns a new hash set with
supplied keys.
and similarly for sorted-set, sorted-set-by.
It rings hollow to say "People don't consider sets, vectors... to have
'keys'" when your own documentation says that keys are what are used
to build sets, or update vectors... and talks about those types using
that term.
>I agree that contains?'s behavior on vectors is confusing for
newcomers. That's not a reason for it to be different. And that people
need a way to do that rummaging job. They of course can, with 'some'.
But I also agree that 'some', being a higher-order function, would not
necessarily be the tool newcomers would consider for the job of
rummaging for a value. Perhaps it's a good first lesson, as they are
not going to find filter-val etc either.
But they will find zero? and wonder, WTF? There be a special function
for #(= 0 %) and not for searching through sequences? (some #(= val
%) ...)
>A) I remove seq-contains?
>B) I rename seq-contains?
Perhaps:
rummage function
Usage: (rummage coll val)
(rummage coll val not-found)
Scans coll looking for val. Returns val if found, else not-found (or
nil).
>I'm inclined towards A so we can all stop wasting time and energy on
this unnecessary function.
An unnecessary function that you just a few paragraphs prior
acknowledged that people need?
Yes, let's do stop "wasting time and energy".
Stuart says that this is FAQ #5, so let's just let it remain that.
And leave the docs as they are, so you can come back again and
thinking about keys and lookup and "misleading expensive operations"
in the wrong way because we only had your docs to read.
But what do I know, I'm just an amateur at wasting time on clojure, I
only have a few measly hours a week. :)
-Doug
--
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