Last active
August 29, 2015 13:57
-
-
Save salvianoo/9380272 to your computer and use it in GitHub Desktop.
Macro newbie
This file contains hidden or 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
| ; Want to do this | |
| => (%w a b c d e f) | |
| ("a" "b" "c" "d" "e" "f") | |
| ; So I wrote a function | |
| (defn %w [& collection] | |
| (map str collection)) | |
| => (%w 1 2 3 4 5) | |
| ("1" "2" "3" "4" "5") | |
| ; But works only with numbers | |
| => (%w a b c d) | |
| ; CompilerException java.lang.RuntimeException: Unable to resolve symbol: a in this context, compiling:(NO_SOURCE_PATH:1:1) | |
| ; Then I tried to write a macro but without success | |
| (defmacro %w [& collection] | |
| (list 'map 'str collection)) | |
| ; What to do?? |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Answer by @pbalduino https://gist.github.com/pbalduino/9380614