Thanks John and Rudiger,<div><br></div><div>Yes, I can and will rewrite the code... I was just shocked at how slow eval was.</div><div><br></div><div>-Joe</div><div><br><br><div class="gmail_quote">On Wed, Jul 18, 2012 at 10:52 PM, Rüdiger Asche <span dir="ltr"><<a href="mailto:rac@ruediger-asche.de" target="_blank">rac@ruediger-asche.de</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><u></u>
<div bgcolor="#ffffff">
<div><font face="Arial">yes it is:</font></div>
<div><font face="Arial"></font> </div>
<div><font face="Arial">(define thunk1 (lambda () (/ 100 10)))<br>(define
thunk2 (lambda () (eval '(/ 100 10))))<br>(define iterate (lambda (ct thunk)
</font></div>
<div><font face="Arial">
(if (zero? ct) </font></div>
<div><font face="Arial">
#t (begin (thunk) (iterate (- ct 1) thunk)))))</font></div><font 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></div></font> </div>
<blockquote style="BORDER-LEFT:#000000 2px solid;PADDING-LEFT:5px;PADDING-RIGHT:0px;MARGIN-LEFT:5px;MARGIN-RIGHT:0px"><div><div class="h5">
<div style="FONT:10pt arial"> </div>
<div style="FONT:10pt arial">----- Original Message ----- </div>
<div style="FONT:10pt arial;BACKGROUND:#e4e4e4"><b>From:</b>
<a title="jgilray@gmail.com" href="mailto:jgilray@gmail.com" target="_blank">Joe Gilray</a>
</div>
<div style="FONT:10pt arial"><b>To:</b> <a title="users@racket-lang.org" href="mailto:users@racket-lang.org" target="_blank">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>
</div></div><p>
</p><hr>
<p></p>____________________<br> Racket Users list:<br>
<a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br><p></p></blockquote>
</blockquote></div><br></div>