;;; Function: SUM_DUPLICATES
;;; Arguments: 
;;;	x: an inventory list of the form ((item1 amt1) (item2 amt2) ...)
;;;	y: an item
;;; Returns: The sum of the amounts for y in the list x
;;; Side effects: none

(defun SUM_DUPLICATES (x y)
  (if (endp x) 			             ; Check if list x is empty 
    0                                        ; if empty return 0
    (if (eq (caar x) y)         	     ; if not empty check if
				             ; first element of the first
				             ; list in x is equal to y 
      (+ (cadar x) (SUM_DUPLICATES (cdr x) y))  
					     ; if so, then add the second
					     ; element of the first list in 
					     ; x to the recursively determined 
					     ; value of SUM_DUPLICATES for the
					     ; rest of x and the same value of
					     ; y. 
      (SUM_DUPLICATES (cdr x) y))))          ; Otherwise, return the value
					     ; SUM_DUPLICATES for the
					     ; rest of x.


