Re: adding line number while reading a file

2009-01-10 Thread James Reeves
On Jan 10, 1:17 pm, GS wrote: > > (with-open [rdr (reader "executors.clj")] > >   (doseq [[line index] (zip-index (line-seq rdr))] > >     (.println System/out (str (inc index) " " line > > Why would you use Java's (.println System/out ...) instead of > (println ...)? Because println is, I t

Re: adding line number while reading a file

2009-01-10 Thread GS
> Next, instead of filter, you probably want doseq. The filter function > filters a collection according to a predicate. The doseq function > applies a function with side effects (such as println) to each item in > a collection. > > (with-open [rdr (reader "executors.clj")] >   (doseq [[line inde

Re: adding line number while reading a file

2009-01-10 Thread Emeka
(map vector (iterate inc 0) "foo") Emeka --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to c

Re: adding line number while reading a file

2009-01-09 Thread Kyle Hargraves
On Fri, Jan 9, 2009 at 9:08 PM, James Reeves wrote: > > On Jan 10, 12:22 am, wubbie wrote: >> How can you add line numbers for each line printed from the file. >> Without line number, I have this: >> >> (with-open [rdr (reader "executors.clj")] >> (filter #(println %) (line-seq rdr))) > > I do

Re: adding line number while reading a file

2009-01-09 Thread James Reeves
On Jan 10, 12:22 am, wubbie wrote: > How can you add line numbers for each line printed from the file. > Without line number, I have this: > > (with-open [rdr (reader "executors.clj")] >   (filter #(println %) (line-seq rdr))) I don't believe there's a function to do this, but it's easy enough t

Re: adding line number while reading a file

2009-01-09 Thread Greg Fodor
My (admittedly newbie) attempt: (with-open [rdr (reader "executors.clj")] (map (partial format "%d: %s") (iterate inc 1) (line-seq rdr))) On Jan 9, 7:22 pm, wubbie wrote: > Hi, > > How can you add line numbers for each line printed from the file. > Without line number, I have this: > > (with-

adding line number while reading a file

2009-01-09 Thread wubbie
Hi, How can you add line numbers for each line printed from the file. Without line number, I have this: (with-open [rdr (reader "executors.clj")] (filter #(println %) (line-seq rdr))) thanks sun --~--~-~--~~~---~--~~ You received this message because you are s