Created
January 28, 2012 19:39
-
-
Save amalloy/1695538 to your computer and use it in GitHub Desktop.
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
| (defn ignore-comments [s] | |
| (-> (reduce (fn [[state output] c] | |
| (case state | |
| :normal (if (= c \/) | |
| [:after-slash output] | |
| [:normal (str output c)]) | |
| :after-slash (case c | |
| \* [:comment output] | |
| \/ [:after-slash (str output "/")] | |
| [:normal (str output "/" c) nil]) | |
| :comment (if (= c \*) | |
| [:after-star output] | |
| [:comment output]) | |
| :after-star (case c | |
| \/ [:normal output] | |
| \* [:after-star output] | |
| [:comment output]))) | |
| [:normal "" nil] | |
| s) | |
| (second))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment