I'm starting to write regular Lisp to me, and I just put it all together and format them.
Suppose I have an alist, for example:
(defvar *map* '((0 . "zero") (1 . "one") (2 . "two")))
How do I format it?
0: zero
1: one
2: two
I thought something like (format t "~{~{~a: ~a~}~%~}" *map*), but this gives an error, because “zero” is not a list, and you cannot take it.
Course making (format t "~{~a~%~}" *map*)prints
(0 . "zero")
(1 . "one")
(2 . "two")
as expected, but that’s not quite what I want. Is there a better way to do this than just (dolist (entry *mapping*) (format t "~a: ~a~%" (car entry) (cdr entry)))?
source
share