Skip to content

Instantly share code, notes, and snippets.

@compwron
Created December 19, 2013 06:01
Show Gist options
  • Save compwron/8035038 to your computer and use it in GitHub Desktop.
Save compwron/8035038 to your computer and use it in GitHub Desktop.
(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!
}" )
@compwron
Copy link
Author

Working w/ two other people at the dojo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment