clojure - Read from a file and return output in a vector -
I'm just learning the closure and trying to read in a file and do something with the returned vector of the result . In this example I am trying to print it.
Below is the code in question:
(defn read_file "Read in a file from the resource directory" [input] (open with [RDR (Reader input)] ( Doseq [line (line-seq rdr)]) (defn -main [] (println (read_file "resource / input.txt"))) println returns a "zero" What should I do to return the "line"?
If the file is not too large, So you use the file to read the content as a string, then make it a specific Divide into the Mankak (in this case with \ n ). (defn read-file [f] (-> (slurp f) (clojure. String / split-lines)))
Comments
Post a Comment