(define longest-list-in-list (lambda (los) (let ((longer-list (lambda (left right) (if (<= (length right) (length left)) left right))) (sam (display "Sam"))) ; Hack to see how many times let is executed. ; If there is only one list, that list must be the longest. (if (null? (cdr los)) (car los) ; Otherwise, take the longer of the first list and the ; longest remaining list. (longer-list (car los) (longest-list-in-list (cdr los))))))) (define longest-list-in-list2 (let ((longer-list (lambda (left right) (if (<= (length right) (length left)) left right))) (sam (display "Samuel"))) ; Hack to see how many times let is executed. (lambda (los) ; If there is only one list, that list must be the longest. (if (null? (cdr los)) (car los) ; Otherwise, take the longer of the first list and the ; longest remaining list. (longer-list (car los) (longest-list-in-list2 (cdr los))))))) ; Format of a let ; (let ((name exp)) ; body) (define largest-in-list (lambda (los) (letrec ((kernel (lambda (los) ; If there is only one list, that list must be the longest. (if (null? (cdr los)) (car los) ; Otherwise, take the longer of the first list and the ; longest remaining list. (max (car los) (kernel (cdr los))))))) (if (not (list? los)) (error 'largest-in-list "Expects a list") (kernel los))))) (define largest-in-list (lambda (los) (let kernel ; The name of a procedure ((stuff los)) ; Param initial value (if (null? (cdr stuff)) (car stuff) (max (car stuff) (kernel (cdr stuff)))))))