我想要做这件事
(format nil "One occurence of ~X , another one: ~X , and yet another one: ~X" #\some-char)
有没有任何 X 格式指令可以实现这个功能?
我想要做这件事
(format nil "One occurence of ~X , another one: ~X , and yet another one: ~X" #\some-char)
找到了:它是~:*
,它告诉Lisp重用上一个参数,就像将参数倒回一位。
有关整个解释段落,请参见:http://www.gigamonkeys.com/book/a-few-format-recipes.html(它在页面底部附近)
因此,它变成了:
(format nil "One occurence of ~C , another one: ~:*~C , and yet another one: ~:*~C" #\a)
=> "One occurence of a , another one: a , and yet another one: a"