Skip to content

Instantly share code, notes, and snippets.

@aethanyc
Created July 11, 2009 07:35
Show Gist options
  • Save aethanyc/145152 to your computer and use it in GitHub Desktop.
Save aethanyc/145152 to your computer and use it in GitHub Desktop.
(set-macro-character #\} (get-macro-character #\)))
(set-macro-character #\{
#'(lambda (stream char)
(declare (ignore char))
(let ((plist (read-delimited-list #\} stream))
(hash (gensym)))
`(let ((,hash (make-hash-table :test #'equal)))
,@(loop for (key value) on plist by #'cddr
collect `(setf (gethash ,key ,hash) ,value))
,hash))))
;;; print hash tables
(set-pprint-dispatch 'hash-table
#'(lambda (stream hash)
(format stream "{~{~{~S ~S~}~^, ~}}"
(loop for k being the hash-key of hash using (hash-value v)
collect (list k v)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment