fork download
  1. (define (f ns)
  2. (define (aux acc ns)
  3. (let* ((n (and (not (null? ns)) (car ns)))
  4. (ns (and n (cdr ns)))
  5. (m1 (and (not (null? acc)) (car acc)))
  6. (m2 (and m1 (not (null? (cdr acc))) (cadr acc))))
  7. (cond
  8. ((not n) m2)
  9. ((not m1) (aux (list n) ns))
  10. ((or (and (not m2) (< m1 n)) (< m1 n m2)) (aux (list m1 n) ns))
  11. ((or (and (not m2) (< n m1)) (< n m1 m2)) (aux (list n m1) ns))
  12. (else (aux acc ns)))))
  13. (aux '() ns))
  14. (print (f '(4 5 1 7 1 2 8 9 2 7)))
  15. (print (f '(1 1 1)))
  16. (print (f '(1)))
  17. (print (f '()))
  18.  
Success #stdin #stdout 0.01s 8100KB
stdin
Standard input is empty
stdout
2
#f
#f
#f