Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (define (moreFrequent l1 l2)
- (cond ((null? l1) l2)
- ((null? l2) l1)
- ((>= (length l1) (length l2)) l1)
- (else l2)))
- (define (mostFrequentList l)
- (if (null? l) '()
- (moreFrequent (filter (lambda (x) (= (car l) x)) l) (mostFrequentList (cdr l)))))
- (define (mostFrequentNum l) (car (mostFrequentList l)))
- (define (mostFrequent l)
- (let ((mostFrequentInFirst (mostFrequentNum (car l))))
- (if (all? (lambda (x) (= (mostFrequentNum x) mostFrequentInFirst)) (cdr l))
- mostFrequentInFirst
- 0)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement