title: Get the size of longest sublist from a list in scheme
body: <p>I would like to get the size of the longest sublist from a list.</p>
  
  <p>for example</p>
  
  <p>(getlongest ((a) b (d e m n) (a d (c m g c y u m l d ) a) ))</p>
  
  <p>returns 9 since (c m g c y u m l d ) has size 9.</p>
  
  <p>I wrote this function</p>
  
  <pre><code>(define getlongest
    (lambda (ls)
      (cond 
       ((null? ls)0)
       (else
        (cond
          ((atom? (car ls))
         (+ 1 (getlongest (cdr ls))))
           (else
            (max (getlongest(car ls)) (getlongest(cdr ls)))))))))
  </code></pre>
  
  <p>However if I write </p>
  
  <p><code>(getlongest ((a) (a (d d d e) m)))</code></p>
  
  <p>i get 5. Can anyone help me to fix this?</p>
  
  <p>Thanks</p>