Program for printing all numbers that user inputs till 42 in Clojure As the name suggests it is a very simple program to print numbers to screen till user inputs 42.

(map 
  println 
  (take-while 
    #(not= % "42") 
    (repeatedly #(.readLine *in*))))


I have started learning Clojure so please share whether there is some easier way to read lines or anything else that can be improved.
I see a few things worth pointing out:

Lazy sequences and side effects

First and foremost, you should be careful about mixing side effects (printing using println) and lazy sequences (such as map, repeatedly, and many more). It may not work the way you expect. Here's an example of side effects just disappearing:

(let [lazy-effects (map println [1 2 3])]
  1)


This doesn't print anything as lazy-effects is never evaluated. There's no need to traverse the lazy sequence, and hence no need to evaluate println on each of the elements. To be sure, your code doesn't suffer from this, as you're evaluating map right in the REPL (or where ever else you're running it), but as soon as you put it inside def or any number of other hidden dangers, it'll no longer get evaluated. Just something to keep in mind.

Using doseq and friends for forcing side effects

With the above in mind, your code would work equally well, but not carry the hidden risk of postponing side effects inside a lazy sequence, if it made use of doseq or some of the other do-like constructs in Clojure. doseq could be used as follows:

(doseq [input (take-while #(not= % "42") (repeatedly read-line))]
  (println input))


If you think this feels slightly less "Clojure-like" in nature, you're right! Side effects generally mix poorly with many of Clojure's core constructs, and special care often needs to be taken. doseq, doall and a few other are provided to help in the case where you really want to force the evaluation of something.

Using read-line from Clojure core

As you probably noticed I managed to sneak in a reference to read-line above, which you might as well be using for this scenario. There is no inherent benefit except the removed need for Java interop.

Otherwise I'd say you're on the right track. The concept of generating an infinite lazy sequence using repeatedly, limiting its length using take-while, and transforming it using map is spot on. It just so happens that this works more painlessly with pure functions that do not cause side effects.