Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

lisp format string that consumes one argument and prints in multiple directive places

I want to do this

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

like image 649
Paralife Avatar asked Mar 01 '11 11:03

Paralife


1 Answers

Found it: It is ~:* It tells lisp to reuse the last argument. Like rewinding the arguments one place back.

For the whole explanation paragraph see: http://www.gigamonkeys.com/book/a-few-format-recipes.html (it is near the bottom of the page)

So it 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"
like image 72
Paralife Avatar answered Sep 19 '22 04:09

Paralife