Idea Solution to problem #3 (abstraction barrier) 

Forum: Com Sci 12500, U Chicago, Autumn 2002, Discuss Classwork
Re: News Final Exam Posted (Dan Hirschberg)
Date: 2002, Dec 11
From: Mike O'Donnell <odonnell@cs.uchicago.edu>

There were a lot of right solutions. Here are my versions:


(define (length_invlist il)

  (sum (map (lambda (s) (nbr_appearances_invlist s il))
            (members_invlist il))))


(define (prefix_list? list1 list2)

  (cond ((null? list1)
          #t)

         (null? list2)
          #f)

         (eq? (car list1) (car list2))
          (prefix_list? (cdr list1) (cdr list2)))

         (else
          #f)))

(define (longand boollist)

  (cond ((null? boollist) #t)

         ((car boollist)  (longand (cdr boollist))

         (else            #f)))

(define (prefix_invlist? il1 il2)

  (longand
    (map (lambda (s) (prefix_list?
                       (locations_invlist s il1)
                       (locations_invlist s il2)))
         (members_invlist il1))))

How many mistakes did I make?




Mike O'D.


Messages

1. Note Looks good, interesting... by Benedict Singer, 2002, Dec 11

to: "Solution to problem #3 (abstraction barrier)"