These problems are intended to help you prepare for the midterm exam. As such, I recommend trying them on paper before using a computer to help you determine whether your solution was correct.
; 1
+ 2 (+ 3 (* 4 (- 5))))
(
; 2
= 4 (+ (* 2 2) (- 4 (- (- 4)))))
(
; 3
let ((x (lambda (y) (+ y y)))
(lambda (q) 4)))
(z (cons (x (z 6)) (z (x 6))))
(
; 4
lambda (y) (+ y 2)) '(1 1 2))
(map (
; 5
cadddr '(1 (2 3) 4 (5)))
(
; 6
let* ((x 2)
(+ 2 x))
(y (lambda (x) (+ x y))))
(f (+ (f x) (f y))) (
Define a Racket function longest-sublist
that takes
a list of lists and returns the length of the longest sublist contained
therein. The length of the longest sublist of the empty list is zero.
Assume that inputs are valid; that is, the input that is either the
empty list or a list of lists. You do not need to check
that this is the case or ensure that your program behaves in any way for
invalid inputs. You may use the max
and length
functions. Here are a couple example cases:
; 0
(longest-sublist '(())) 1) (1 2) (1 2 3) (1))) ; 3 (longest-sublist '(() (