Indeed. If you omit `in-range', this can have a big cost on performance on
nested loops (I observe almost a factor 10 on this small example).

Note that you can also write a nested for loop with `for*':
(for* ([i (in-range 10000)]
       [j (in-range 1000)])
  (void))




On Mon, Apr 2, 2018 at 10:33 AM, 若草春男 <whbug...@gmail.com> wrote:

> Thank you, Laurent.
>
> I mind the performance of in-range, but it seems to be no problem.
>
> #lang racket
>
> (time (for ([i (in-range 10000)])
>         (for ([j (in-range 1000)])
>           (void))))
>
> (time (do ([i 0 (+ i 1)]) ([= i 10000])
>         (do ([j 0 (+ j 1)]) ([= j 1000])
>           (void))))
>
> cpu time: 110 real time: 106 gc time: 0
> cpu time: 109 real time: 111 gc time: 0
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to