Lisp format a character a number of times

后端 未结 4 1052
天命终不由人
天命终不由人 2020-12-01 21:08

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?

<
4条回答
  •  旧时难觅i
    2020-12-01 21:53

    Like the answer of Lars, but we write the character wih ~C, instead of using the printer with ~A:

    (format nil "~v@{~C~:*~}" 3 #\*)
    

    Writing a character with something like write-char is a simpler operation than printing a Lisp object. The printer has a lot of context to observe and has to find the right way to print the object. OTOH, something like WRITE-CHAR just writes a single character to a stream.

提交回复
热议问题