Nothing happens inside my Clojure cycle

I have a little code that doesn't want to work at all when I execute a loop, as shown below:

...

    (defn my-function []
        (println "Hi")   ;this works
        (for [i (range 10)] (println "Hello")  ;this doesn't work!
          )
    )

...

I don’t understand what the problem is, all the code inside the loop seems to be ignored, and β€œHello” prints without problems

I call "myfunction" through a GUI button event, for example:

...
    (.append output-text (with-out-str  (time (my-function))))
...

Do you think that a problem may arise in the GUI or something else that I am missing? Any suggestion? I know that I should use REPL for testing, but it does not work with Netbeans ...: S

Many thanks for your help.

+5
source share
2 answers

The macro is forlazy, so it will not call your function unless the return value is actually required.

doseq. , , . "", for, , println.

+10

- "", , , (, println). :

(defn my-function[]
  (println "Hi")
  (dorun (for [i (range 10)] (println "Hello"))))
+3

All Articles