将数字转换为Lisp中的字符串 [英] converting number to string in lisp
本文介绍了将数字转换为Lisp中的字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图找到一个在数字和字符串之间转换的lisp函数,经过一番谷歌搜索之后,我喜欢了一个同名函数.当我输入(itoa 1)
SLIME打印时:
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) .
如何进行转换?
推荐答案
从数字到字符串:
(write-to-string 5)
"5"
您可以将字符串转换为任何数字符号:
you may transform a string to any numerical notation:
(write-to-string 341 :base 10)
"341"
从字符串到数字:
(parse-integer "5")
5
有一些垃圾
(parse-integer " 5 something not a number" :junk-allowed t)
5
或使用此:
(read-from-string "23 absd")
23
这篇关于将数字转换为Lisp中的字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文