Re: matching symbols in a dictionary

2010-04-14 Thread Christophe Grand
On Wed, Apr 14, 2010 at 9:33 AM, Jeff Rose wrote: > I recently discovered condp, which is good for doing the equivalent of > a switch statement and more: > > (map > (fn [[k v]] >(condp = k > :a (* 2 v) > :b (* 3 v))) > {:a "foo" :b "bar"}) > for true switch statements (with c

Re: matching symbols in a dictionary

2010-04-14 Thread Jeff Rose
On Apr 13, 11:34 pm, strattonbrazil wrote: > I want to map a dictionary and do different things depending on the > key.  I was planning on using an if-clause, but I'm not sure how to > compare symbols to strings. > > Something like > > (map (fn [k v] (if (== k "hello") ... ...) {:hello 1 :goodbye

Re: matching symbols in a dictionary

2010-04-13 Thread Josh Stratton
> You do mean keywords rather than symbols, right? A symbol would be > 'hello. A keyword is :hello. > The ruby name for the clojure keyword concept is "symbol". I used to > get the terminology backwards because of that. > > (assert (= (name :hello) "hello")) > (assert (= :hello (keyword "hello")))

Re: matching symbols in a dictionary

2010-04-13 Thread Travis
You do mean keywords rather than symbols, right? A symbol would be 'hello. A keyword is :hello. The ruby name for the clojure keyword concept is "symbol". I used to get the terminology backwards because of that. (assert (= (name :hello) "hello")) (assert (= :hello (keyword "hello"))) On Apr 13, 2

matching symbols in a dictionary

2010-04-13 Thread strattonbrazil
I want to map a dictionary and do different things depending on the key. I was planning on using an if-clause, but I'm not sure how to compare symbols to strings. Something like (map (fn [k v] (if (== k "hello") ... ...) {:hello 1 :goodbye 2}) How would I normally compare symbols and strings?