Benny already answered, but here's the common block that I'm using for
my Clojure submissions:
(import '(java.io BufferedReader FileReader))
(defn process-file [file-name]
(let [rdr (BufferedReader. (FileReader. file-name))]
(line-seq rdr)))
(defn my-func [col]
; Do something interesting
)
(println (my-func (process-file (first *command-line-args*))))
Basically I read the lines of the file into a sequence, then process
that sequence in my function. Since I'm only dealing with the first
parameter passed to my script, a (first *command-line-args*) call is
equivalent to args[0] in other languages like Java.
On Jan 16, 5:03 pm, "Randy J. Ray" <[email protected]> wrote:
> On 01/12/2011 11:50 PM, Robert McIntyre wrote:
>
> > They seem to allow you to include anything in a lib directory that you'd
> > want.
>
> > I sometimes include apache commons-io and clojure-contrib1.2 without
> > any problems.
> > I also included a sql connection library for one of the problems, so
> > it seems fine :)
>
> For those puzzles that require command-line processing, have you used a
> library
> to do it? Looking in both "Programming Clojure" and "Practical Clojure", the
> only instruction I can find on handling command-line args involves AOT
> compilation of your class and definition of a -main method. I'm not sure how
> well this would work with the submission model that Coderloop uses.
>
> I'm afraid I'm still *very* new to Clojure, and while it would be easy (for
> me)
> to solve the problems in other languages, the point of the exercise (for me)
> is
> to use Coderloop's problems to help myself in learning Clojure...
>
> Randy
>
> --
> """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
> """"
> Randy J. Ray Sunnyvale, CA http://www.rjray.org
> [email protected] http://www.svsm.org
> [email protected]
> http://twitter.com/rjray
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
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