Skip to content

Instantly share code, notes, and snippets.

@lispm
Last active December 12, 2015 01:58
Show Gist options
  • Save lispm/4694973 to your computer and use it in GitHub Desktop.
Save lispm/4694973 to your computer and use it in GitHub Desktop.
; http://tapestryjava.blogspot.se/2013/02/crafting-code-in-clojure.html
;
; Extract all the keys from both maps
; Remove any duplicates
; Convert the keys to strings
; Sort the strings into ascending order
; Build and return one big string, by concatenating all the key strings, using ", " as a separator
; Return "<none>" if both maps are empty
(defun hash-table-keys (hash-table)
(loop for key being the hash-key of hash-table collect key))
(defun example (&rest hash-tables)
(format nil "~:[<none>~;~:*~{~A~^, ~}~]"
(sort (remove-duplicates (mapcan 'hash-table-keys hash-tables) :test #'equal)
'string<)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment