1?-use_module(library(lists)). 2?-prolog_flag(single_var_warnings,_,off). 3 4 5 6/* Emulates the gensym(2) function */ 7 8gensym(A,B) :- get_num(A,Num), 9 name(A,Name1), 10 name(Num, Name2), 11 append(Name1,Name2,Name), 12 name(B,Name). 13 14/* Emulates the init_gensym(1) function */ 15 16init_gensym(A) :- asserta(current_num(A,0)). 17 18/* get_num(2) */ 19 20get_num(A,Num) :- 21 retract(current_num(A,Num1)), !, 22 % writeln(Num1), 23 Num is Num1+1, 24 asserta(current_num(A,Num)). 25 26get_num(A,1) :- asserta(current_num(A,1)). 27 28/* Emulates the writenl(1) function */