home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / p / plbin.zip / pl / library / gensym.pl < prev    next >
Text File  |  1992-05-26  |  599b  |  34 lines

  1. /*  gensym.pl,v 1.1.1.1 1992/05/26 11:51:36 jan Exp
  2.  
  3.     Copyright (c) 1990 Jan Wielemaker. All rights reserved.
  4.     jan@swi.psy.uva.nl
  5.  
  6.     Purpose: play with gensym
  7. */
  8.  
  9. :- module(gensym,
  10.     [ reset_gensym/0
  11.         , gensym/2
  12.     ]).
  13.  
  14. :- style_check(+dollar).
  15.  
  16. gensym(Base, Atom) :-
  17.     concat($gs_, Base, Key), 
  18.     flag(Key, Old, Old), 
  19.     record_gensym(Key, Old),
  20.     succ(Old, New), 
  21.     flag(Key, _, New), 
  22.     concat(Base, New, Atom).
  23.  
  24. record_gensym(Key, 0) :- !,
  25.     recordz($gensym, Key).
  26. record_gensym(_, _).
  27.  
  28. reset_gensym :-
  29.     recorded($gensym, Key, Ref),
  30.         erase(Ref),
  31.         flag(Key, _, 0),
  32.     fail.
  33. reset_gensym.
  34.