Lisp 多次格式化一个字符 [英] Lisp format a character a number of times

查看:17
本文介绍了Lisp 多次格式化一个字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种输出字符的方法多次使用格式.这可能吗?有人可以填吗在 _?_ 中,以便示例有效?

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 "_?_" _?_ #* _?_ ))

应该返回

=> "***"

推荐答案

很高兴看到这么多解决方案:~A、~< 和 ~{ 到目前为止.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆