library(strings) defines three predicates for generating atoms.
gensym(+Prefix, -Atom)
concat_atom([Prefix, N], Atom),
where
N is the next number in the sequence associated with Prefix.
Notionally, each Prefix has its own counter, starting with
zero. Prefix must be an atom. Examples:
| ?- gensym(a, X).
X = a1
| ?- gensym(a, X).
X = a2
| ?- gensym(b, X).
X = b1
| ?- gensym(1, X).
no
gensym(-Atom)
%. Example:
| ?- gensym(X).
X = '%58'
cgensym(+Prefix, ?Atom)
gensym/2. Otherwise, Prefix and Atom should be
atoms. The name is to be read as "conditionally generate
symbol".
These predicates are included for compatibility with the DEC-10 Prolog
library, which has contained them for several years.
cgensym/2 will do nothing to Atom if it is already bound; otherwise it
is just like gensym/2.