[an error occurred while processing this directive]

Class 21 Notes

Lecture Slides, Suitable For Printing

Lazy Data

How does lazy evaluation enable infinite data structures?






(define ints-from
    (lambda (n)
       (cons n (ints-from (+ n 1)))))
(define fibo-gen (lambda (a b)
     (cons a (fibo-gen ____  __________))))

(define fibos (fibo-gen 0 1))

(define get-nth (lambda (lst n)
   (if (= n 0) (car lst) (get-nth (cdr lst) (- n 1)))))

(define fibo (lambda (n) (get-nth _______ n)))
(define merge-lists
   (lambda (lst1 lst2 proc)
      (if (null? lst1) null
           (if (null? lst2) null
               (cons (proc (car lst1) (car lst2))
                      (merge-lists (cdr lst1) (cdr lst2) proc))))))

(define fibos
   (cons 0 (cons 1 (merge-lists ___________  ______________ +))))

Types

When is it a good idea to give up expressiveness?




What is the difference between manifest and latent types?




What is the difference between static and dynamic type checking?




What does increasing the strictness of a language's type checking do?




What are the advantages and disadvantages of static type checking?




Type Language

CType ::= CPrimitiveType
CType ::= CProcedureType
CType ::= CProductType

CPrimitiveType ::= Number | Boolean
CProcedureType ::= ( CProductType -> Type)
CProductType ::= ( CTypeList )
CTypeList ::= CType CTypeList
CTypeList ::=

What is the type of: