erikb@cs.vu.nl (Erik Baalbergen) (11/30/90)
How can I dynamically construct atom '12' in Pereira's C-Prolog (version 1.5)? Apparently, I cannot use name/2. Both name(12, L) and name('12', L) bind L to [49,50], but name(N, [49,50]) binds N to integer 12, not to atom '12'. Please respond by email to erikb@cs.vu.nl . Erik Baalbergen PS. Please don't tell me that name(N, [39,49,50,39]) is the solution :-) -- Erik H. Baalbergen <erikb@cs.vu.nl> Vrije Universiteit / Dept. of Maths. & Comp. Sc. De Boelelaan 1081 1081 HV Amsterdam / The Netherlands tel. +31 20 548 8080
lang@PRC.Unisys.COM (Francois-Michel Lang) (12/01/90)
In article <8389@star.cs.vu.nl> erikb@cs.vu.nl (Erik Baalbergen) writes: >How can I dynamically construct atom '12' in Pereira's C-Prolog (version 1.5)? >Apparently, I cannot use name/2. Both name(12, L) and name('12', L) bind >L to [49,50], but name(N, [49,50]) binds N to integer 12, not to atom '12'. The short answer is: You can't. This problem is precisely the reason for built-ins like atom_chars/2 and number_chars/2 in Quintus Prolog, because there are perfectly legitimate atoms like '12' which cannot be constructed by name/2. If you get really desperate, you could always write out '12'. to a file and then read it back in :-) ---------------------------------------------------------------------------- Francois-Michel Lang (215) 648-2536 Unisys Center for Advanced Information Technology lang@prc.unisys.com Dept of Comp & Info Science, U of PA lang@linc.cis.upenn.edu