Clojure: using *command-line-args* in the script rather than REPL
Posted
by Teflon Mac
on Stack Overflow
See other posts from Stack Overflow
or by Teflon Mac
Published on 2010-05-14T06:57:09Z
Indexed on
2010/05/14
7:04 UTC
Read the original article
Hit count: 178
clojure
I've clojure running within Eclipse. I want to pass arguments to clojure when running it. In the below the arguments are available in the REPL but not in the script itself. What do I need to do such that in the below typing arg1 in the REPL will return the first argument?
Script:
(NS Test)
(def arg1 (nth *command-line-args* 0))
After clicking on the Eclipse "Run"...
Clojure 1.1.0
1:1 user=> #<Namespace test>
1:2 test=> arg1
nil
1:3 test=> *command-line-args*
("bird" "dog" "cat" "pig")
1:4 test=> (def arg2 (nth *command-line-args* 1))
#'test/arg2
1:5 test=> arg2
"dog"
1:6 test=>
© Stack Overflow or respective owner