Created
February 25, 2012 06:28
-
-
Save tomfaulhaber/1906914 to your computer and use it in GitHub Desktop.
Simple pprint on a deftype
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
user> (deftype Foo [a b c]) | |
user.Foo | |
user> (def f (Foo. "The quick brown fox jumped over the" "lazy dog" "Friends, Romans, and Countrymen, lend me your ears")) │···· | |
#'user/f | |
user> (def e (Foo. 1 2 3)) | |
#'user/e | |
user> (defn augmented-dispatch [f] | |
(if (instance? Foo f) | |
(cl-format true | |
"~<{~;~<a ~_~w~:>, ~_~<b ~_~w~:>, ~_~<c ~_~w~:>~;}~:>" | |
[[(.a f)] [(.b f)] [(.c f)]]) | |
(simple-dispatch f))) | |
#'user/augmented-dispatch | |
user> (with-pprint-dispatch augmented-dispatch (pprint [e f])) | |
[{a 1, b 2, c 3} | |
{a "The quick brown fox jumped over the", | |
b "lazy dog", | |
c "Friends, Romans, and Countrymen, lend me your ears"}] | |
nil | |
user> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment