Created
December 19, 2013 06:01
-
-
Save compwron/8035038 to your computer and use it in GitHub Desktop.
Clojure Dojo - http://codekata.pragprog.com/2007/01/kata_thirteen_c.html
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
(use 'clojure.string) | |
(defn first-parts-are? [s test-string] | |
(let [cleaned-string (subs s 0 (min | |
(count test-string) | |
(count s)))] | |
(= test-string cleaned-string))) | |
(defn is-a-comment [line] | |
(some true? (map | |
(partial first-parts-are? line) | |
["*" "/**" "//"]))) | |
(defn count-code-lines [s] | |
(let [ready-lines (map trim (split-lines our-string)) | |
total (count splitted) | |
commented-lines (count | |
(filter is-a-comment splitted))] | |
(- total commented-lines))) | |
(def our-string " // This file contains 3 lines of code | |
public interface Dave { | |
/** | |
* count the number of lines in a file | |
*/ | |
int countLines(File inFile); // not the real signature! | |
}" ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Working w/ two other people at the dojo