gensym builtin for SWI emulation.
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1423 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
parent
41405ff41a
commit
9dbbd43e54
24
library/gensym.yap
Normal file
24
library/gensym.yap
Normal file
@ -0,0 +1,24 @@
|
||||
:- module(gensym, [
|
||||
gensym/2,
|
||||
reset_gensym/1,
|
||||
reset_gensym/0
|
||||
]).
|
||||
|
||||
:- dynamic gensym_key/2.
|
||||
|
||||
gensym(Atom, New) :-
|
||||
retract(gensym_key(Atom,Id)), !,
|
||||
atomic_concat(Atom,Id,New),
|
||||
NId is Id+1,
|
||||
assert(gensym_key(Atom,NId)).
|
||||
gensym(Atom, New) :-
|
||||
atomic_concat(Atom,1,New),
|
||||
assert(gensym_key(Atom,2)).
|
||||
|
||||
reset_gensym(Atom) :-
|
||||
retract(gensym_key(Atom,_)).
|
||||
|
||||
reset_gensym :-
|
||||
retractall(gensym_key(_,_)).
|
||||
|
||||
|
Reference in New Issue
Block a user