Write a program that given a number of documents, can find all the documents with words containing the letter "a" in them.
with-openmacro that will automatically close any I/O. The
clojure.string/includes?function will check each line as it comes in if it contains the letter "a" and will return true or false.
(defn contains-a? [document] (with-open [rdr (clojure.java.io/reader document)] (clojure.string/includes? (line-seq rdr) "a"))) (filter #(contains-a? %) [documents])
Next step is to:
try and succeed as fast as possible, i.e once the program detects an "a" it should return true and stop looking through that file and,
AsynchronousFileChannelof Java plus
core.asyncto maybe parallelize the work? Not sure how this would work.