Functional Problem Solving (CSC 151 2015S) : EBoards
Primary: [Front Door] [Schedule] - [Academic Honesty] [Disabilities] [Email] - [FAQ] [Teaching & Learning] [Grading] [Taking Notes] [Rubric] - [Calendar]
Current: [Assignment] [EBoard am] [EBoard pm] [Lab] [Outline] [Reading]
Sections: [Assignments] [EBoards am] [EBoards pm] [Labs] [Outlines] [Readings] - [Examples] [Handouts]
Reference: [Setup] [VM] [Errors] - [Functions A-Z] [Functions By Topic] - [Racket] [Scheme Report (R5RS)] [R6RS] [TSPL4]
Related Courses: [Davis (2013F)] [Rebelsky (2014F)] [Weinman (2014F)]
Misc: [Submit Questions] - [SamR] [Glimmer Labs] [CS@Grinnell] [Grinnell] - [Book Office Hours] - [Issue Tracker (Course)]
Overview
listp? predicate.Nothing at present
What should we take from yesterday's lab?
Why are we studying this?
Print
If you have a pair
print a single quotation mark
print an open parentheis
print the car
move on to the cdr
^ if the cdr is null
| print a close paren and stop
| if the cdr is a pair
| print a space
| print the car
+---+ loop back and do it all over again
| otherwise
| print a space
| print a curse
| print a space
| print the cdr
| print a right paren
listp?Write a procedure, (listp? val) that returns #t if val is a list and
Reminder: A list is null or (cons VAL LIST)
(define listp?
(lambda (val)
(or (null? val)
(and (pair? val)
(listp? (cdr val))))))