string-gensym.red 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. %
  2. % STRING-GENSYM.RED - Complement to GenSym, makes a string instead of ID
  3. %
  4. % Author: Eric Benson
  5. % Symbolic Computation Group
  6. % Computer Science Dept.
  7. % University of Utah
  8. % Date: 14 January 1982
  9. % Copyright (c) 1982 University of Utah
  10. %
  11. % Edit by Cris Perdue, 9 Feb 1983 1620-PST
  12. % Modified to avoid using the CHAR macro in a top level form
  13. fluid '(StringGenSym!*);
  14. StringGenSym!* := copystring("L0000"); % Copy to force into heap /csp
  15. CompileTime flag('(StringGenSym1), 'InternalFunction);
  16. lisp procedure StringGenSym(); %. Generate unique string
  17. StringGenSym1 4;
  18. lisp procedure StringGenSym1 N; %. Auxiliary function for StringGenSym
  19. begin scalar Ch;
  20. return if N > 0 then
  21. if (Ch := Indx(StringGenSym!*, N)) < char !9 then
  22. << SetIndx(StringGenSym!*, N, Ch + 1);
  23. TotalCopy StringGenSym!* >>
  24. else
  25. << SetIndx(StringGenSym!*, N, char !0);
  26. StringGenSym1(N - 1) >>
  27. else % Increment starting letter
  28. << SetIndx(StringGenSym!*, 0, Indx(StringGenSym!*, 0) + 1);
  29. StringGenSym() >>;
  30. end;
  31. END;