3

If I have a running REPL, can I print out all symbols that have been defined? Is there some way to know what has been defined in the REPL I'm using?

ftravers
  • 3,809
  • 3
  • 37
  • 38

3 Answers3

1

In order to be able to know what symbols have been defined in a namespace in your REPL use the following code:

    (keys (ns-publics 'my-name-space))  

This answser comes from this Stackoverflow post. How to list the functions of a namespace?

Use the code below to print to a string.

    (pr-str (keys (ns-publics 'my-name-space)))

Below is a full example in the form of a screenshot taken of LightTable.

enter image description here

Community
  • 1
  • 1
Udesh
  • 1,919
  • 3
  • 20
  • 26
0

First, you need to find all namespaces:

(all-ns)

Then, you must decide what you want to collect. For example, the documentation on namespaces lists the following functions for examining namespaces:

For example, you can have all intern mappings like this:

(reduce conj (map ns-interns (all-ns)))
coredump
  • 37,664
  • 5
  • 43
  • 77
0

There is also the dir macro, to list a namespace:

user=> (dir user)
nil
user=> (def x :a)
#'user/x
user=> (dir user)
x
nil
user=> (dir clojure.core)
*
*'
*1
*2
*3
*agent*...
cfrick
  • 35,203
  • 6
  • 56
  • 68