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>