【发布时间】:2017-07-11 05:52:51
【问题描述】:
我能做什么:
CL-USER> (format nil "~10:<foobar~>")
" foobar"
但我想将10 作为参数传递:
CL-USER> (format nil "~d:<foobar~>" 10) ;; but throws error
" foobar"
有没有办法做到这一点?因为我不想那样做:
CL-USER> (format nil (format nil "~~~d:<foobar~~>" 10))
" foobar"
在 Python 或 C 中,可以使用 * 将变量参数传递给控制字符串,如下所示:
print("%*s" % (10, "foobar"))
我想要 Common Lisp 格式的一样。提前致谢。
【问题讨论】:
标签: format common-lisp