Help on 9.) pleaseImplement the bag as a scheme list of these pair.docx

This preview shows page 1 - 4 out of 4 pages.

Image of page 1

Subscribe to view the full document.

help on 9.) please Implement the bag as a scheme list of these pairs (with the car holding a reference to a pair and the cdr holding a reference to the rest of the list). Therefore, the bag above would be represented as: '(("a" . 2) ("b" . 1) ("c" . 1)) 9.) (unionBag ListA ListB)-return a new bag that represents the result of the union of the two given bags (combine the contents of both- take the sum of the frequencies of each element in the two bags) can use any of these functions: ;0 (define (getValue Pair) (car Pair) ) ;1 (define (getCount Pair) (cdr Pair) ) ;2 (define (newPair item) (cons item 1) ) ;3 (define (incPair Pair) ( cons (car Pair) (+ 1 (cdr Pair))) )
Image of page 2
;4 (define (decPair Pair) ( cons (car Pair) (- (cdr Pair) 1)) ) ;5 (define (insertBag List item)
Image of page 3

Subscribe to view the full document.

Image of page 4
  • Fall '19

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Ask Expert Tutors You can ask 0 bonus questions You can ask 0 questions (0 expire soon) You can ask 0 questions (will expire )
Answers in as fast as 15 minutes