gpt4 book ai didi

使用一个参数并在多个指令位置打印的 lisp 格式字符串

转载 作者:太空宇宙 更新时间:2023-11-03 18:40:15 25 4
gpt4 key购买 nike

我想做这个

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

是否有任何 X 格式指令可以做到这一点?

最佳答案

找到了:它是 ~:* 它告诉 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"

关于使用一个参数并在多个指令位置打印的 lisp 格式字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5153817/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com