On Nov 17, 2008, at 13:33, mb wrote:

> vals returns a clojure.lang.APersistentMap$ValSeq, which
> is not a list. Hence list? returns false and you get the true
> branch, ie. the thing itself.

Ahhhh..... It looks like a list, but it isn't a list.

> I know. It doesn't help much, but it shows, that you have to take
> care to distinguish the abstraction vs. the specific implementation.

That's fine with me in principle, but not if the language makes an  
effort to hide the implementation from me.

A fix that works (at least for the examples I tried) is

(defn replace-syms
    [sym-map expr]
    (let [replace #(replace-syms sym-map %)]
       (cond (contains? sym-map expr) (get sym-map expr)
            (vector? expr) (into [] (map replace expr))
            (map? expr) (into {} (map replace (seq expr)))
            (set? expr) (set (map replace expr))
            (seq? expr) (map #(replace-syms sym-map %) expr)
            :else expr)))

I have moved the seq? test to the end just in case that one day  
vectors, sets, or maps implement the seq interface as well.

Thanks for your quick reply,
   Konrad.


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

Reply via email to