diff options
Diffstat (limited to 'challenge-072/tyler-wardhaugh/clojure/src/tw/weekly/c72/t2.clj')
| -rw-r--r-- | challenge-072/tyler-wardhaugh/clojure/src/tw/weekly/c72/t2.clj | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/challenge-072/tyler-wardhaugh/clojure/src/tw/weekly/c72/t2.clj b/challenge-072/tyler-wardhaugh/clojure/src/tw/weekly/c72/t2.clj new file mode 100644 index 0000000000..072a02ef1e --- /dev/null +++ b/challenge-072/tyler-wardhaugh/clojure/src/tw/weekly/c72/t2.clj @@ -0,0 +1,18 @@ +(ns tw.weekly.c72.t2 + (:require [clojure.java.io :as io]) + (:require [clojure.edn :as edn]) + (:require [pjstadig.reducible-stream :refer [decode-lines!]])) + +(defn lines-from + "Produce a range of lines from a file" + [file a b] + (let [xf (comp (drop (dec a)) (take (- b a -1))) + source (decode-lines! file)] + (sequence xf source))) + +(defn -main + "Run Task 2 with a file and range of lines to print, defaulting to the first example in the task description" + [& args] + (let [file (or (some-> args first io/file) (io/resource "input.txt")) + [a b] (or (some->> args (drop 1) (take 2) (map edn/read-string)) [4 12])] + (dorun (map println (lines-from file a b))))) |
