Soccerplayer13 0 Newbie Poster

I came accross this problem and I was wondering if anyone could help...
Consider this data definition that a company uses to keep track of the substances it stores in its factory:

;; A tank is 
;; (make-tank string number)
(define-struct tank (substance quantity))

Some examples would be:

(make-tank "oil" 25) 
(make-tank "distilled water" 10)

Write the function combine. You give it a list of tanks and it combines all the like substances together into one big tank of the correct size, returning a list of the new tanks.
For example:

(combine (cons (make-tank "water" 7) 
         (cons (make-tank "oil" 10)
         (cons (make-tank "water" 2)
         (cons (make-tank "vinegar" 3)
         (cons (make-tank "vinegar" 1)
         (cons (make-tank "water" 3) empty)))))))
"should be"
(cons (make-tank "water" 12)
      (cons (make-tank "oil" 10)
            (cons (make-tank "vinegar" 4) empty)))

Thank you

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.