title: Scheme mode function
body: <p>I am trying to find the mode of a list</p>
  
  <p>Assuming the list is sorted ascending order</p>
  
  <p>Here is my mode function</p>
  
  <pre><code> (define freq
     (lambda (l)
       (cond ((null? l)l)
             ((null? (cdr l))l)
             ((not(equal? (car l) (car(cdr l))))(freq(cdr(delete l (car l)))))
             (else (freq (cdr l)))
   )))
  
     (freq '(4 4 4 4 5 7 9 9 9)) =&gt; should returns 4 but its returning 9 instead
  </code></pre>