Prolog: how to convert string to integer?

Viewed 22592

So as the title says - how do you convert a string into an integer? the idea is something like this:

convert(String,Integer).

examples:
convert('1',1).
convert('33',33).

I'm using swi prolog

5 Answers

Quite an old, but there is a predicate in SWI Prolog: number_string(N, S).

Docs

number_string(123, S).
S = "123".

For those who are still looking for it.

Related