Getting the number from the list of character codes
?- number_codes(N,[49, 50, 51]). % the UCS-2 char codes for '1','2','3' N = 123. ?- number_codes(N,[45, 50, 51]). % 45 is the UCS-2 char code for '-' N = -23. ?- number_codes(N,[43, 50, 51]). % 43 is the UCS-2 char code for '+' N = 23. ?- number_codes(N,[49, 50, 46, 49, 50]). N = 12.12. ?- number_codes(N,[42, 50, 51]). % 42 is the UCS-2 char code for '*': NOPE! ERROR: Syntax error: Illegal number
A bit more readable: use 0'X notation, which results in the char code for character X:
?- number_codes(N,[0'+, 0'4, 0'5]). N = 45.
Getting the list of character codes from a number
?- number_codes(-12,L). L = [45, 49, 50]. ?- number_codes(+12,L). L = [49, 50]. ?- number_codes(12.12,L). L = [49, 50, 46, 49, 50].