Last active
December 12, 2015 01:58
-
-
Save lispm/4694973 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; 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