[racket] How best to repeat a function call n times?

From: George Rudolph (rudolphg1 at citadel.edu)
Date: Mon Sep 15 13:50:10 EDT 2014

All,
I am sure this question has been answered before, but I can't find it.
Suppose I want to call some function, either built-in or user-defined, n number of times, and measure the total time it takes. Is there a more efficient or elegant way
of doing this than passing the expression to a tail-recursive counting loop such as the following?

(define (repeater sexpr count)
  (sexpr)
  (cond
    [(> count 0) (repeater sexpr (- count 1)) ])
)



George Rudolph
Associate Professor of Computer Science
Department of Mathematics and Computer Science
225 Thompson Hall
The Citadel
171 Moultrie Street
Charleston, SC 29409
843.953.5032

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20140915/938e5bc6/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.gif
Type: image/gif
Size: 92 bytes
Desc: image001.gif
URL: <http://lists.racket-lang.org/users/archive/attachments/20140915/938e5bc6/attachment.gif>

Posted on the users mailing list.