Lisp format string that consumes a single argument and prints in several places in the directive

I want to do it

(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?

+4
source share
1 answer

Found: ~:* It tells lisp to reuse the last argument. How to rewind arguments one place back.

For the entire explanation of the paragraph, see http://www.gigamonkeys.com/book/a-few-format-recipes.html (located at the bottom of the page)

So he 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" 
+4
source

Source: https://habr.com/ru/post/1341795/


All Articles