All pastes #25901 Raw Edit

Something

public text v1 · immutable
#25901 ·published 2005-10-18 22:43 UTC
rendered paste body
(defun somarlista (L1 L2)
  (if (null L1) L2
      (if (null L2) L1
          (cons (+ (first L1) (first L2))
                   (somarlista (rest L1) (rest L2))))))

(defun subtrairlista (L1 L2)
  (if (null L2) L1
      (if (null L1) (cons (- 0 (first L2)) (subtrairlista L1 (rest L2)))
          (cons (- (first L1) (first L2))
                (subtrairlista (rest L1) (rest L2))))))

(defun multiplicarlista(L1 L2)
  (if (null L2) NIL
      (if (null L1) NIL
          (somarlista (mapcar #'(lambda(x) (* x (first L1))) L2)
                (multiplicarlista (rest L1) L2)))))

(defun derivarlista(L1 n)
  (if (null L1) NIL
      (if (= 0 n) NIL
          (cons (* n (first L1)) (derivarlista (rest L1) (- n 1))))))


(defstruct poli o p)


(defun somarpoli(p1 p2)

  (make-poli
   :o (max (poli-o p1) (poli-o p2))
   :p (somarlista (poli-p p1) (poli-p p2))
   ))