0

I made a simple function in Clojure to print some values.

(defn printboard [] (
    (dotimes [n 3]
      (println n)
      )
    )
  )

(printboard)

Now when i run this code as an application, it gives me an NullPointerException. When i run the code in the REPL it works perfect. Why does my code give me an NullPointerExeption in the application but not in the REPL?

1 Answer 1

3

You are wrapping dotimes inside parentheses. Try the below code

(defn printboard []
    (dotimes [n 3]
      (println n)))

(printboard)

Try it online!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.