Scheme mode function
问题 I am trying to find the mode of a list Assuming the list is sorted ascending order Here is my mode function (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)) => should returns 4 but its returning 9 instead 回答1: Here's my solution, which is similar to Óscar's solution but centralises the update of the longest/winning result in one place: (define (longest-run lst)