20-CS-4003-001 Organization of Programming Languages Fall 2017

Lambda calculus, Type theory, Formal semantics, Program analysis

    Prev     Next     All lectures        Code

Procedures: Maximum Number in a List

(define findmax
  (lambda (lst)
    (if (null? lst)
        (if (null? (cdr lst))
            (car lst)
            (max (car lst)
                 (findmax (cdr lst)))))))
 -  Find the maximum number in a list. Example: Now is the time to
   prompt> (findmax '(8 3 4 9 1 2))
   ;Value: 9