请帮我定义一个这样的字符串..
我有一个包含值的列表 (定义临时列表(列表'398'150'1.15'2875'-900'1565'800'230'200'0'0'0))
我应该声明为...... (定义b“398 150 1.15 2875 -900 1565 800 230 200 0 0 0”)
我怎么能在计划中这样做?
答案 0 :(得分:2)
如果您已加载SRFI 13,则可以使用string-join
,如下所示:
(define b (string-join (map number->string temp-list)))
答案 1 :(得分:1)
请参阅http://codepad.org/8DH8mCTQ:
(define temp-list (list '398 '150 '1.15 '2875 '-900 '1565 '800 '230 '200 '0 '0 '0))
(define b
(let loop ((xs temp-list) (zs '()))
(if (null? (cdr xs))
(apply string-append (reverse (cons (number->string (car xs)) zs)))
(loop (cdr xs) (cons " " (cons (number->string (car xs)) zs))))))
(write b)