[plt-scheme] testing if a variable is bound

From: Danny Yoo (dyoo at hkn.eecs.berkeley.edu)
Date: Wed Jan 11 04:43:54 EST 2006


> How does one test if a variable is bound?
>
> MIT/GNU Scheme has this:
> http://www.gnu.org/software/mit-scheme/documentation/scheme_14.html


Hi Geoffrey,

I think something like namespace-mapped-symbols from the namespace
utilities may do the trick:

http://download.plt-scheme.org/doc/300/html/mzscheme/mzscheme-Z-H-8.html#node_sec_8.3

For example:

;;;;;;
> (and (member 'square (namespace-mapped-symbols)) #t)
#f
> (define square (lambda (x) (* x x)))
> (and (member 'square (namespace-mapped-symbols)) #t)
#t
;;;;;;


Best of wishes!



Posted on the users mailing list.