6

Итерация с помощью loop

(loop for key being the hash-keys of *my-hash*
        do (print key))
; FIRST-KEY 
; SECOND-KEY 
; THIRD-KEY 
; NIL 
; NIL
(loop for key being the hash-keys of *my-hash*
        using (hash-value value)
        do (format t "The value associated with the key ~S is ~S~%" key value))
; The value associated with the key FIRST-KEY is ONE
; The value associated with the key SECOND-KEY is TWO
; The value associated with the key THIRD-KEY is NIL
; The value associated with the key NIL is NIL-VALUE
; NIL
(loop for value being the hash-values of *my-hash*
        do (print value))
; ONE 
; TWO 
; NIL 
; NIL-VALUE 
; NIL
(loop for value being the hash-values of *my-hash*
        using (hash-key key)
        do (format t "~&~A -> ~A" key value))
; FIRST-KEY -> ONE
; SECOND-KEY -> TWO
; THIRD-KEY -> NIL
; NIL -> NIL-VALUE
; NIL
-----------