Not more efficient, but perhaps more readable:

(define (repeater f count)
  (for ([x (in-range count)])
    (f)))


On Mon, Sep 15, 2014 at 12:50 PM, George Rudolph <rudolp...@citadel.edu>
wrote:

>   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
>
>
>
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users
>
>
____________________
  Racket Users list:
  http://lists.racket-lang.org/users

Reply via email to