Here's a code snippet that I wrote, but doesn't work:
(let ((separator "|")
(text '("Just" "do" "it" "!")))
(format t "~{~A~A~%~}" text separator))
The output should look like:
Just|
do|
it|
!|
However, it won't work like that - when I'm inside ~{~}
, I don't know how I can add elements from outside the list. I could do this:
(format t "~{~A|~%~}" text)
but this does not allow me to use separator
from variable, and that's what I'm after.
Now I know that I could merge text
with separator, by adding separator in every even place, but that looks ugly to me. Is there other way to do it in format
?