[racket] Is eval very slow?

From: Joe Gilray (jgilray at gmail.com)
Date: Thu Jul 19 01:15:29 EDT 2012

Hi,

I've written some code that uses eval:

  (define ops (list * / + -))
  (define digits '(1 2 3 4 5))
  (for ([dl (combinations 4 digits)])
    (define lst '())
    (for ([d (permute-all dl)])
      (for* ([o1 ops] [o2 ops] [o3 ops])
        (unless (and (eq? o1 /) (zero? (eval (list o2 (second d) (list o3
(third d) (fourth d))))))  ; avoid divide by zero
          (define val (eval (list o1 (first d) (list o2 (second d) (list o3
(third d) (fourth d))))))
          (when (>= val 1) (set! lst (cons val lst)))) ...

It runs very, very slowly.  Am I doing something wrong?  Is there a way to
speed up eval?

Thanks,
-Joe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20120718/d1e0a4bc/attachment.html>

Posted on the users mailing list.