; Terribly tentative derivative function. (lambda (e v) (let deriv ((e e)) (if (number? e) 0 (if (pair? e) (let ((head (car e))) (if (or (eq? head '+) (eq? head '-)) `(,head ,@(let ds ((el (cdr e))) (if (null? el) '() (cons (deriv (car el)) (ds (cdr el)))))) (if (eq? head '*) (if (not (= (length (cdr e)) 2)) 'po* `(+ (* ,(cadr e) ,(deriv (caddr e))) (* ,(deriv (cadr e)) ,(caddr e)))) (if (eq? head 'exp) `(* ,(deriv (cadr e)) (exp ,(cadr e))) 'poX)))) (if (symbol? e) (if (eq? e v) 1 0) 'poY))))) ((fileVal "deriv") '(+ (* r 3) (* s r) (- s 2)) 'r)