我尝试做类似的事情:
assume x=
(define foo 5)
我需要这样做:
(string-append "a" "b" (cadr x))
(当x不知道..)
如何将var(cadr x)转换为字符串或者还有其他的闷闷不乐?
由于
答案 0 :(得分:0)
要将数字转换为字符串,请使用number->string
过程:
(number->string 5)
=> "5"
要将符号转换为字符串,请使用symbol->string
过程:
(symbol->string 'x)
=> "x"
一些例子,选择一个能更好地反映你需求的例子 - 因为你不清楚你打算在问题中提出什么:
(define foo 5)
(string-append "a" "b" (number->string foo))
=> "ab5"
(define x '(1 5))
(string-append "a" "b" (number->string (cadr x)))
=> "ab5"
(define x '(define foo 5))
(string-append "a" "b" (number->string (caddr x)))
=> "ab5"
(define x '(define foo 5))
(string-append "a" "b" (symbol->string (cadr x)))
=> "abfoo"