1

I need to convert a Prolog atom to an integer. For example:

?- convert('123', X).
X = 123
yes

I have seen some SO answers about that, but they rely on SWI-Prolog, and I am forced to use SICStus Prolog. Casting to string will also do the job, as I am aware of the number_codes/2 predicate.

Thanks for your help.

false
  • 10,264
  • 13
  • 101
  • 209
sygi
  • 4,557
  • 2
  • 32
  • 54

1 Answers1

3

Ok, I found an answer (in case you too need it):

atom_chars('123', Y), number_chars(X, Y).
sygi
  • 4,557
  • 2
  • 32
  • 54