rhombidodecahedron
rhombidodecahedron

Reputation: 7922

Use the elements of the list in a format function

I want to do something like:

(setf list '(1 2 3 4 5 6))
(format t "~A some text here ~A ~A ~A more text here ~A ~A" list)

And have the output be

1 some text here 2 3 4 more text here 5 6

How can I do this without calling (nth 1 list) (nth 2 list) etc?

Upvotes: 2

Views: 119

Answers (2)

Xach
Xach

Reputation: 11839

(format t "~{~A some text here ~A ~A ~A more text here ~A ~A~}" list)

Upvotes: 11

huaiyuan
huaiyuan

Reputation: 26549

Try

(apply #'format t "~A some text here ~A ~A ~A more text here ~A ~A" list)

Upvotes: 7

Related Questions