Advertisement
Guest User

Wow! NewLisp

a guest
Apr 20th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 1.44 KB | None | 0 0
  1. ;перевощикова маша
  2. ;мех-мат, 1 курс, 3 группа, 2000 год
  3. ;(wrs 'differen.prt)
  4. ;(setq echo t)
  5. ;(setq traceflag nil)
  6. ;(defun aaa (l)
  7. ; (trace (l))
  8. ;  (cond (traceflag (traceprint l))
  9. ;        (t nil))
  10. ;) ; trace
  11. ;(defun traceprint (l)
  12. ;    (terpri)
  13. ;    (princ l)
  14. ;) ; traceprint
  15.  
  16. (defun dif (l x)
  17.   (cond ((atom l) (cond ((eq l x) 1)
  18.                         ( t       0)))
  19.         ((eq (car l) '+) (list '+ (dif (second l) x) (dif (third l) x)))
  20.         ((eq (car l) '*) (list '+ (list '* (dif (second l) x) (third l))
  21.                                   (list '* (dif (third l) x) (second l))))
  22.         ((eq (car l) '/) (list '/ (list '- (list '* (dif (second l) x) (third l))
  23.                                            (list '* (dif (third l) x) (second l)))
  24.                                   (list '^ (third l) 2)))
  25.         ((eq (car l) '-) (list '- (dif (second l) x) (dif (third l) x)))
  26.         ((eq (car l) '^) (list '* (third l) (list '^ (second l) (- (third l) 1))))
  27.         ((eq (car l) 'sin) (list '* (dif (second l) x) (list 'cos (second l))))
  28.         ((eq (car l) 'cos) (list '- (list '* (dif (second l) x) (list 'sin (second l)))))
  29.         ((eq (car l) 'tg) (list '/ (dif (second l) x) (list '^ (list 'cos (second l) 2))))
  30.         ((eq (car l) 'ln) (list '/ (dif (second l) x) (second l)))
  31.         (t l)))
  32.        
  33. (print (dif '(/ 3 5 6 89 4) 3))
  34. (print t)
  35. (print (/ (- (* 1 5) (* 0 3)) (^ 5 2)) )
  36. ;(rds)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement