Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

converting number to string in lisp

I tried to find a lisp function to convert between numbers and strings and after a little googling I fond a function with the same name. when I entered (itoa 1) SLIME printed:

Undefined function ITOA called with arguments (1) . 

How can I do the conversion?

like image 482
elyashiv Avatar asked Apr 25 '13 16:04

elyashiv


1 Answers

From number to string:

(write-to-string 5) "5" 

you may transform a string to any numerical notation:

(write-to-string 341 :base 10) "341" 

From string to number:

(parse-integer "5") 5 

with some trash

(parse-integer " 5 something not a number" :junk-allowed t) 5 

Or use this:

(read-from-string "23 absd") 23 
like image 159
edem Avatar answered Oct 05 '22 13:10

edem