1

I'm trying to learn clojure, but coming from OO background simple things look like mission impossible. For instance, how do I write the function that would accept console input and output it into console as well?

I'm trying something like this, but it doesn't work.

(ns ClojureTest2.core)

,(defn fun [] 
   (let [input (read-line)]) 
   (println input)
 )

(fun [])

P.S. I work with eclipse - counterclockwise

Caballero
  • 11,546
  • 22
  • 103
  • 163
  • you probably don't want to hear this but...ditch eclipse. If you spend the time to learn emacs along with nrepl and paredit, your life will become infinitely more simple. I would suggest you start with emacs live until you're ready to build up your own config - https://github.com/overtone/emacs-live – PTBG Sep 25 '13 at 01:55

1 Answers1

1

Try this:

(ns ClojureTest2.core)

(defn fun []
  (let [input (read-line)]
    (println input)))

(fun)

Note how the println is enclosed in the let statement. input will only exist within the let statement. Also, the empty parameter list of fun means you do not need to supply any arguments to call it.

Jared314
  • 5,181
  • 24
  • 30