> I don't see any way to significantly improve your speed, but I can
> save you some lines of code:

Thanks! I ended up calling out to grep instead :) Here is the code if
someone else wants to do similar things:

(defn real-grep [pattern]
  (debug (str "pattern: " pattern))
  (let [cmd-arr
        (into-array ["C:\\pgm\\bin\\grep.exe" "-i" pattern "c:\\home\
\gbgfs1_archive75_file_listing.txt"])
        proc (. (. java.lang.Runtime (getRuntime)) (exec cmd-arr))
        lines (binding [*in* (new java.io.BufferedReader
                                  (new java.io.InputStreamReader
                                       (. proc (getInputStream))))]
                (loop [line (read-line) acc nil count 0]
                  (if (and line (< count 1000))
                    (recur (read-line)
                           (if acc
                             (cons line acc)
                             (list line))
                           (inc count))
                    acc)))]
    lines))

As you can see I also had to limit the number of hits returned. One
search I did that gave over 50000 hits resulted in a exception
(something about heap memory being exhaused I think).

/Mathias
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to