sstteevvee
Programmer
Hey guys, I'm trying to get an input from the user as a string consisting only of numbers and converting it to a list of integers. I can read the string in and convert it to a list of characters but i don't know how to convert these characters to integers, or how to convert the origional string to a list of integers..? Anyways, here is my code to convert to a list of characters, is there a way to convert these to integers or a better way of achieving this??
convert :-
fmt_read("%s",X,_),
atom_chars(X,L),
write(L), nl.
eg:
$convert.
123058469
X = [1,2,3,0,5,8,4,6,9].
convert :-
fmt_read("%s",X,_),
atom_chars(X,L),
write(L), nl.
eg:
$convert.
123058469
X = [1,2,3,0,5,8,4,6,9].