Erebus Mons <erebus.m...@gmail.com> writes:

> I am reading in a csv-file, and then transform the attributes into a
> hash-map:
>
> __________________________________________________________________________
> name,property1,property2,etc
> John,drunk,stinks,etc.
> etc.
> __________________________________________________________________________
>
> {"John" {:property1 "drunk", :property2 "stinks"} etc

Why a map of maps and not a map of sets, e.g.:

  {"John" #{"drunk" "stings"}}

Then your predicates just turn into membership checks instead of having
to search through the values of the properties map.  That is, drunk? is
just:

  (defn drunk? [person-prop-map person]
    (contains? (person-prop-map person) "drunk))

> then I create with a function functions like drunk?, so that I can
> check whether John is drunk
>
> (drunk? "John")
> true
>
> I need to be able to get all properties in the map but
> drunk?. Therefore, I thought it would be handy to be able to filter
> out drunk? from the functions, but I figured I can only do that if I
> can treat the function-name like a name...

You need to filter it out in order not to define the same function
several times, or do I get you wrong?

If so, why not get the unique set of properties after building the map,
and then generate one predicate for any property that occured?

  ;; If the props are storted as sets like suggested above, then...
  (apply clojure.set/union (vals person-prop-map))
  ;; ...gives you the set of unique property names.

HTH,
Tassilo

-- 
-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to