Try:

(contains? (ns-map *ns*) 'foo)

*ns* binds to the current namespace.

On Thu, Feb 12, 2009 at 7:10 PM, Conrad <drc...@gmail.com> wrote:

>
> Hi, is there a standard way to tell if a variable is bound? I couldn't
> find a way.
> Basically I want something like this, but without the horrible hacks:
>
> (defn bound? [var]
>    (try (eval var)
>           true
>           (catch java.lang.Exception x false)))
>
> > (bound? 'foo)
> false
> > (def foo 33)
> 33
> > (bound? 'foo)
> true
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to