Re: Why does this not give output

2014-08-06 Thread Thomas Heller
dotimes is for doing things n times. doseq is for seqs. Use dotimes when you can, doseq when you can't. On Wed, Aug 6, 2014 at 12:13 AM, Cecil Westerhof cldwester...@gmail.com wrote: 2014-08-05 19:04 GMT+02:00 Thomas Heller th.hel...@gmail.com: If you don't need the result of the for loop

Re: Why does this not give output

2014-08-06 Thread Cecil Westerhof
2014-08-06 9:48 GMT+02:00 Thomas Heller i...@zilence.net: dotimes is for doing things n times. doseq is for seqs. Use dotimes when you can, doseq when you can't. ​OK, I thought so, but wanted to be sure.​ And I also use doseq on a place where dotimes would not work: (doseq [arrayRange

Why does this not give output

2014-08-05 Thread Cecil Westerhof
I wanted to play again with Clojure. ;-) I wanted to test the random generator. For this I wrote: (def intArr (make-array Integer 10)) (for [i (range 10)] (aset intArr i (int 0))) (for [i (range 1)] (let [index (rand-int 10)] (aset intArr index (int (inc (aget intArr index)) (for

Re: Why does this not give output

2014-08-05 Thread Michael Klishin
On 5 August 2014 at 19:41:03, Cecil Westerhof (cldwester...@gmail.com) wrote: ​When run in the REPL it gives the output I expect, but when executed as a program, it does not give any output at all. What is going on here? Because `for` is lazy. In the REPL the result has to be computed

Re: Why does this not give output

2014-08-05 Thread Thomas Heller
If you don't need the result of the for loop (which you don't in your example) use doseq. Same syntax as for but not lazy and no return value (well, nil to be exact) (doseq [i (range 10)] (aset intArr i (int 0))) ... On Tuesday, August 5, 2014 5:41:08 PM UTC+2, Cecil Westerhof wrote: I

Re: Why does this not give output

2014-08-05 Thread Cecil Westerhof
2014-08-05 19:04 GMT+02:00 Thomas Heller th.hel...@gmail.com: If you don't need the result of the for loop (which you don't in your example) use doseq. Same syntax as for but not lazy and no return value (well, nil to be exact) ​I already use dotimes, or is doseq better?​ -- Cecil