RosettaCodeData/Task/Read-a-specific-line-from-a-file/Clojure/read-a-specific-line-from-a-file.clj
2023-07-01 13:44:08 -04:00

5 lines
215 B
Clojure

(defn read-nth-line
"Read line-number from the given text file. The first line has the number 1."
[file line-number]
(with-open [rdr (clojure.java.io/reader file)]
(nth (line-seq rdr) (dec line-number))))