开发者

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

开发者 https://www.devze.com 2023-02-14 06:29 出处:网络
I want to do this (format nil \"One occurence of ~X , another one: ~X , and yet another one: ~X\" #\\some-char)

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

精彩评论

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