i have a script in clojure that can read a string of integers separated by commas from a file..the scrip is succesful and reads the line from the file as astring,all i want is some clojure loop to scan the string for integers and add to an integer array
here is the code

(ns Files.myfile)
(defn hello-world []
  (println "Hello World"))
 (hello-world)
(def s (slurp "integers.txt"))
  (println s)
(s)

##integers.txt contains random integers separated by commas

Recommended Answers

All 2 Replies

Not sure if this is what you're looking for, but it seems to work:

(ns Files.myfile)
(require '[clojure.string :as str])
(defn hello-world []
  (println "Hello World"))
 (hello-world)
(def s (map read-string(str/split(slurp "integers.txt") #",")))
  (println s)

the last line in your code seems to be a typo. This post has more info.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.