Maybe something along these lines:
(def ^{:private true} EMPTY (reify))
(defn get-with-empty-check [map key]
(get map key EMPTY))
(defn key-exists? [value]
(not= EMPTY value))
=> (def res (get-with-empty-check {:asdf 1} :ss))
EMPTY
=> (key-exists? res)
false
The basic idea being that it's guaranteed nothing will ever equal EMPTY
other than itself, making it easy to determine if a key is missing.
Ambrose
On Sun, Mar 20, 2011 at 7:22 PM, Andreas Kostler <
[email protected]> wrote:
> Hi Ambrose,
> No java interop. I do a selection based on map keys. Suppose I have a set
> of maps:
> (def rel #{{:a "a" :b "b"}{:a "c" :b "d"}{:a "e" :b "f"}})
> And I do a select-like query
> (select rel [[:a :eq "a"]])
> => #{{:a "a" :b "b"}}
>
> Now, I want to distinguish between a value that doesn't match and a
> non-existing key.
> Hence,
> (select rel [[:bogus "b"]]) should not return an empty set but somehow
> signal that the key does not exist.
> In relational terms, the key is not an attribute of the relation.
> Does that make sense?
> Andreas
>
> On 20/03/2011, at 9:10 PM, Ambrose Bonnaire-Sergeant wrote:
>
> > curious, why do you want to do this? Are you working with Java interop
>
>
> --
> 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
>
--
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