2014-10-20 Lab+HW

posted Oct 20, 2014, 5:41 AM by Samuel Konstantinovich   [ updated Oct 20, 2014, 5:41 AM ]
Goal Look into sublists:

New Method: (list? x)  is true when x is a list, false otherwise.

(define MrE (lambda (L) 
              (cond 
                ( (null? L)       0 )
                ( (list? (car L)) (+ (MrE (car L))(MrE (cdr L))) )
                (  else           (+ (car L) (MrE (cdr L))) )
                )))

Expand and evaluate on paper:
(MrE '( 1 ( 2 ) (3 4) ) )



LAB + Finish as Homework 15. Bring in a printed copy tomorrow with your heading.
1. (countAtomsSub L)  -> how many atoms does a list have, including sublists.

2. (maxListSub L) -> What is the largest atom in a list including its sublists.
Comments