Ryan said it all. But since I decided to check on the long-forgotten do loops, 
I thought I'd show you the one-liner: 

> (do ([x 10 (- x 1)]) ((zero? x)) (displayln x))
10
9
8
7
6
5
4
3
2
1

Loops are ugly -- Matthias




On Dec 9, 2010, at 1:51 PM, Luke Jordan wrote:

> Here's a rookie question that stems from HtDP 29.3.2.
> 
> The idea is to test an expression a number of times while timing it and 
> compare to another version of the same function.  The expression finds a 
> route in a vector (graph) from node 0 to node 4.  The way I would do this in 
> C/Python is with a while loop, while the counter is not zero execute the 
> expression (ignore return value), and wrap it in the timer.  In Racket I came 
> up with:
> 
> (time (for-each
>        (lambda (dest) (find-route 0 dest Graph))
>        (make-list 1000 4)))
> 
> It seems unnecessarily tricky, but I couldn't think of a better way.  Am I 
> missing a piece?  Does it only seem tricky because Racket is my first 
> functional language.
> 
> aTdHvAaNnKcSe
> 
> ^ actually unnecessarily tricky
> 
> Luke
> 
> 
> _________________________________________________
>  For list-related administrative tasks:
>  http://lists.racket-lang.org/listinfo/users

_________________________________________________
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/users

Reply via email to