1
votes

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.

1

1 Answers

3
votes

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

atom_chars('123', Y), number_chars(X, Y).