lecture7

# lecture7 - Class 7 List Procedures Click to edit Master...

This preview shows pages 1–7. Sign up to view the full content.

Click to edit Master subtitle style 2/19/10 Class 7: List Procedures David Evans cs1120 Fall 2009

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
2/19/10 List Recap A List is either: (1) a Pair whose second part is a List or (2) null Pair primitives: (cons a b) Construct a pair <a, b> 22
2/19/10 List Examples > null () > (cons 1 null) (1) > (list? null) #t > (list? (cons 1 2)) #f > (list? (cons 1 null)) #t 33

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
2/19/10 More List Examples > (list? (cons 1 (cons 2 null))) #t > (car (cons 1 (cons 2 null))) 1 > (cdr (cons 1 (cons 2 44
2/19/10 List Procedures Be very optimistic! Since lists themselves are recursive data structures, most problems involving lists can be solved with recursive procedures. Think of the simplest version of the problem , something you can already solve. This is the base case. For lists, 55

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
list-trues Define a procedure that takes as input a list, and produces as output the number of non-false values in the list. (list-trues null) P
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 13

lecture7 - Class 7 List Procedures Click to edit Master...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online