On 15.11.2008, at 23:29, Stephen C. Gilardi wrote:
>> But there is no islist?, nor anything that looks equivalent. So how
>> do I test if form is a list? Or a vector? Or a map? For processing
>> general forms, I'd need to handle all of these, right? Or is there a
>> simpler way to do it?
>
> You can use list? vector? and map?.
Ahh, thanks. That gives:
(defn replace-syms
[sym-map expr]
(let [replace #(replace-syms sym-map %)]
(cond (contains? sym-map expr) (get sym-map expr)
(list? expr) (map #(replace-syms sym-map %) expr)
(vector? expr) (into [] (map replace expr))
(map? expr) (into {} (map replace (seq expr)))
(set? expr) (set (map replace expr))
true expr)))
which seems to work just fine.
> To find all predicates that clojure defines, you can do this search:
>
> user=>(find-doc "[?]")
Thanks even more, that's a real life-saver!
Konrad.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---