Step Eval Common Lisp -


i have been trying find method "step" eval. call function , evaluates nested list common lisp.

for example:

'(+ 2 (+ 3 4)) ; eval to: '(+ 2 7) 

in example evaluated 3 + 4 , stopped right there. did not continue on eval 2 + 7 lisp do.

so want code find nested list , eval nested list, without evaluating whole list.

for example:

'(+ 2 3 4 5 (+ 4 5 (- 5 6) 1 (+ 10 8 5 (- 10 11))) 10 7) 

it find nested list, (- 10 11), , eval so:

'(+ 2 3 4 5 (+ 4 5 (- 5 6) 1 (+ 10 8 5 -1)) 10 7) 

again evaluates once, , not evaluate whole list @ once.

does know how go make step evaluation nested list? use eval or execute nested part of list without evaling whole list @ once? problem i'm having don't know how evaluate nested list , put together. don't know how approach this. please enlighten me on how master lisper this.

the order of evaluation left-to-right, not right evaluate deepest nested list if want emulate common lisp's behaviour.

you rather have evaluate first nested form first. assuming well-formed input:

(defun step-eval (form)   (let ((sub-index (position-if #'listp form)))     (if sub-index         ;; there deeper list step first         (append (subseq form 0 sub-index)                 (list (step-eval (nth sub-index form)))                 (subseq form (1+ sub-index)))         ;; no deeper list, eval         (eval form)))) 

Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -