lisp - Efficient evaluation of spliced lists with a recurring argument -


i want recur through list of slot names of classes, same slot names 2 classes ((current-trial *exp*) & (previous *exp*) refer instances of same class). on each recursion, want evaluate slot name value of slot of instance may got , set. code below meets expectation, worry relying upon eval because it's slow , doesn't allow lexical context (graham, 1996). alternative formulations efficient , allow lexical context?

(dolist (a '(letter number font color height))   (eval     `(when (eq (,a (current-trial *exp*))                (,a (previous *exp*)))      (setf (,a (current-trial *exp*))             (random-not-item              (,a (current-trial *exp*))              (,a *exp*)))))) 

since these slot names, can use slot-value:

(dolist (a '(letter number font color height))   (when (eq (slot-value (current-trial *exp*) a)              (slot-value (previous *exp*) a))     (setf (slot-value (current-trial *exp*) a)            (random-not-item             (slot-value (current-trial *exp*) a)             (slot-value *exp* a))))) 

Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -