Lisp多次格式化一个字符 [英] Lisp format a character a number of times
本文介绍了Lisp多次格式化一个字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在寻找一种使用格式输出字符
多次的方法。这可能吗?有人可以在 _?_
中填写
,这样这个例子可以工作吗?
<$ p $ ($($))
(格式nil_?__)_ $ _ $ _ $ code >
应该返回
=> ***
解决方案
解决方案:〜A,〜<,〜〜{到目前为止。
〜@ iteration构造提供了一个简洁的解决方案:
(format nil〜v @ {〜A〜:*〜}3#\ *)
I am looking for a way to output a character
a number of times using format. Is this possible? Can someone fill
in the _?_
's, so that the example works?
(let ((n 3))
(format nil "_?_" _?_ #\* _?_ ))
should return
=> "***"
解决方案 It's nice to see so many solutions: ~A, ~<, and ~{ so far.
The ~@{ iteration construct provides a concise solution:
(format nil "~v@{~A~:*~}" 3 #\*)
这篇关于Lisp多次格式化一个字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文