开发者

lisp format string that consumes one argument and prints in multiple directive places

I want to do this

(format nil "One occurence of ~X , another one: ~X , and yet another one: ~X" #\some-char)

Is there any X format directive that can do开发者_运维问答 this?


Found it: It is ~:* It tells lisp to reuse the last argument. Like rewinding the arguments one place back.

For the whole explanation paragraph see: http://www.gigamonkeys.com/book/a-few-format-recipes.html (it is near the bottom of the page)

So it becomes

(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"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜