gensym

clojure.core

  • (gensym)
  • (gensym prefix-string)
Returns a new symbol with a unique name. If a prefix string is
supplied, the name is prefix# where # is some unique number. If
prefix is not supplied, the prefix is 'G__'.

2 Examples top

  • user=> (gensym "foo")
    foo2020
    
    user=> (gensym "foo")
    foo2027
    
    user=> (gensym "foo")
    ;; ...
    
  • user=> (gensym)
    G__2034
    
    user=> (let [my-unique-sym (gensym)]
             my-unique-sym)
    G__2075
    
Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/core.clj:525 top

(defn gensym
  "Returns a new symbol with a unique name. If a prefix string is
  supplied, the name is prefix# where # is some unique number. If
  prefix is not supplied, the prefix is 'G__'."
  {:added "1.0"
   :static true}
  ([] (gensym "G__"))
  ([prefix-string] (. clojure.lang.Symbol (intern (str prefix-string (str (. clojure.lang.RT (nextID))))))))
Vars in clojure.core/gensym:
Used in 0 other vars

Comments top

No comments for gensym. Log in to add a comment.