[racket] Rookie Question on Functional Languages

From: Luke Jordan (luke.jordan at gmail.com)
Date: Thu Dec 9 13:51:12 EST 2010

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.


^ actually unnecessarily tricky

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20101209/fd31b74e/attachment.html>

Posted on the users mailing list.