lecture7

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

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

View Full Document Right Arrow Icon
Click to edit Master subtitle style 2/19/10 Class 7: List Procedures David Evans cs1120 Fall 2009
Background image of page 1

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

View Full DocumentRight Arrow Icon
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
Background image of page 2
2/19/10 List Examples > null () > (cons 1 null) (1) > (list? null) #t > (list? (cons 1 2)) #f > (list? (cons 1 null)) #t 33
Background image of page 3

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

View Full DocumentRight Arrow Icon
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
Background image of page 4
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
Background image of page 5

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

View Full DocumentRight Arrow Icon
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
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

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 Right Arrow Icon
Ask a homework question - tutors are online