Thunfische
Thunfische

Reputation: 1157

How to store a string in an array in clojure

    (defn file-read
      [filename]
      (with-open
        [r (clojure.java.io/reader filename)]
        (doseq
          [line (line-seq r)]
          *here i want to store the line in an array of strings or something*
          )
        )
      )

After reading the line from a text document, i want to store it. I am new to clojure and have no idea how to do this.

Upvotes: 0

Views: 396

Answers (2)

Alex Ott
Alex Ott

Reputation: 87119

instead of (doseq [line (line-seq r)] ...) just use (doall (line-seq r)) - it will force evaluation of the line-seq into sequence, and return it.

Upvotes: 1

9000
9000

Reputation: 40884

I suspect that doseq is not needed and into-array would suffice.

Upvotes: 0

Related Questions