SHARE
TWEET

Untitled

a guest Dec 12th, 2019 78 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (define (moreFrequent l1 l2)
  2.   (cond  ((null? l1) l2)
  3.          ((null? l2) l1)
  4.          ((>= (length l1) (length l2)) l1)
  5.          (else l2)))
  6.  
  7. (define (mostFrequentList l)
  8.   (if (null? l) '()
  9.     (moreFrequent (filter (lambda (x) (= (car l) x)) l) (mostFrequentList (cdr l)))))
  10.  
  11. (define (mostFrequentNum l) (car (mostFrequentList l)))
  12.  
  13. (define (mostFrequent l)
  14.   (let ((mostFrequentInFirst (mostFrequentNum (car l))))
  15.   (if (all? (lambda (x) (= (mostFrequentNum x) mostFrequentInFirst)) (cdr l))
  16.       mostFrequentInFirst
  17.       0)))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top