<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=iso-8859-1" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 8.00.6001.18928">
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT size=2 face=Arial>yes it is:</FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT> </DIV>
<DIV><FONT size=2 face=Arial>(define thunk1 (lambda () (/ 100 10)))<BR>(define
thunk2 (lambda () (eval '(/ 100 10))))<BR>(define iterate (lambda (ct thunk)
</FONT></DIV>
<DIV><FONT size=2
face=Arial>
(if (zero? ct) </FONT></DIV>
<DIV><FONT size=2
face=Arial>
#t (begin (thunk) (iterate (- ct 1) thunk)))))</FONT></DIV><FONT size=2
face=Arial>
<DIV><BR>(time (iterate 1000000 thunk1))<BR> => cpu time: 15 real time:
16 gc time: 0<BR><BR>(time (iterate 1000000 thunk2))<BR>=> cpu time: 21110
real time: 21125 gc time: 436</DIV>
<DIV> </DIV>
<DIV></FONT> </DIV>
<BLOCKQUOTE
style="BORDER-LEFT: #000000 2px solid; PADDING-LEFT: 5px; PADDING-RIGHT: 0px; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px">
<DIV style="FONT: 10pt arial"> </DIV>
<DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV
style="FONT: 10pt arial; BACKGROUND: #e4e4e4; font-color: black"><B>From:</B>
<A title=jgilray@gmail.com href="mailto:jgilray@gmail.com">Joe Gilray</A>
</DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A title=users@racket-lang.org
href="mailto:users@racket-lang.org">Racket mailing list</A> </DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Thursday, July 19, 2012 7:15
AM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> [racket] Is eval very
slow?</DIV>
<DIV><BR></DIV>Hi,
<DIV><BR></DIV>
<DIV>I've written some code that uses eval:</DIV>
<DIV><BR></DIV>
<DIV>
<DIV> (define ops (list * / + -))</DIV>
<DIV> (define digits '(1 2 3 4 5))</DIV>
<DIV> (for ([dl (combinations 4 digits)])</DIV>
<DIV> (define lst '())</DIV>
<DIV> (for ([d (permute-all dl)])</DIV>
<DIV> (for* ([o1 ops] [o2 ops] [o3 ops])</DIV>
<DIV> (unless (and (eq? o1 /) (zero? (eval (list o2
(second d) (list o3 (third d) (fourth d)))))) ; avoid divide by
zero</DIV>
<DIV> (define val (eval (list o1 (first d)
(list o2 (second d) (list o3 (third d) (fourth d))))))</DIV>
<DIV> (when (>= val 1) (set! lst (cons
val lst)))) ...</DIV></DIV>
<DIV><BR></DIV>
<DIV>It runs very, very slowly. Am I doing something wrong? Is
there a way to speed up eval?</DIV>
<DIV><BR></DIV>
<DIV>Thanks,</DIV>
<DIV>-Joe</DIV>
<P>
<HR>
<P></P>____________________<BR> Racket Users list:<BR>
http://lists.racket-lang.org/users<BR></BLOCKQUOTE></BODY></HTML>