Skip to content

Instantly share code, notes, and snippets.

@DuqueDeTuring
Created December 28, 2011 19:50
Show Gist options
  • Select an option

  • Save DuqueDeTuring/1529386 to your computer and use it in GitHub Desktop.

Select an option

Save DuqueDeTuring/1529386 to your computer and use it in GitHub Desktop.
Reescritura del ejemplo de for clojure-loc, del libro "Programming Clojure" usando una operación sobre listas distinta
;Reescritura del ejemplo de for clojure-loc, del libro "Programming Clojure" usando una operación sobre listas distinta
;Rewrite of "Programming Clojure"'s clojure-loc for example with a different list comprehension
(use '[clojure.java.io :only (reader)])
(defn non-blank? [line] (if (re-find #"\S" line) true false))
(defn clojure-source? [file] (.endsWith (.toString file) ".clj"))
(defn clojure-loc2 [base-file]
(reduce +
(map
#(with-open [rdr (reader %)] (count (filter non-blank? (line-seq rdr))))
(filter clojure-source? (file-seq base-file)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment