converting number to string in lisp

前端 未结 3 1919
失恋的感觉
失恋的感觉 2021-02-01 18:08

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) SLI

3条回答
  •  终归单人心
    2021-02-01 18:35

    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
    

提交回复
热议问题