Functional Problem Solving (CSC 151 2013F) : Labs
Primary: [Front Door] [Schedule] - [Academic Honesty] [Disabilities] [Email] [FAQ] [IRC] [Teaching & Learning] [Grading]
Current: [Assignment] [EBoard] [Lab] [Outline] [Partners] [Reading]
Sections: [Assignments] [EBoards] [Examples] [Handouts] [Labs] [Outlines] [Partners] [Readings]
Reference: [Setup] - [Functions A-Z] [Functions By Topic] - [Racket] [Scheme Report (R5RS)] [R6RS] [TSPL4]
Related Courses: [Davis (2013F)] [Rebelsky (2010F)] [Weinman (2012F)]
Misc: [SamR] [Glimmer Labs] [CS@Grinnell] [Grinnell] [Issue Tracker (Course)]
Summary: In this laboratory, you will further ground your understanding of what happens “behind the scenes” when Scheme deals with lists and other pair-based structures.
Make sure you have some blank pieces of paper (lined is okay) and something with which to write.
Draw box-and-pointer diagrams for each of the following lists:
((x) y z)(x (y z))((a) b (c ()))Be prepared to share your pictures with me.
Enter each of the following expressions into Scheme. In each case, explain why Scheme does or does not use the dot notation when displaying the value.
(cons 'a "Walker")(cons 'a null)(cons 'a "null")(cons 'a "()")(cons null 'a)(cons null (cons null null))Draw a box-and-pointer representation of the value of the last two expressions in the previous exercise.
What do you think that pair? will return for each of the
following? How about list?. Attempt to confirm each answer
experimentally and explain any that you found particularly tricky.
(cons 'a 'b)(cons 'a (cons 'b 'c))(cons 'a null)null(list 'a 'b 'c)(list 'a)(list)You may recall that we told you that many kinds of data are defined recursively. For example, a list is either (1) null or (2) cons of anything and a list.
Using that recursive definition of lists, write a procedure,
(,
that determines whether or not listp? val)val is a list.
You may not use list? in your definition
of listp?.
If you were able to complete the primary exercises with time to spare, you might want to consider the following problems:
-->listp?
Write listp? without using if or cond.
Primary: [Front Door] [Schedule] - [Academic Honesty] [Disabilities] [Email] [FAQ] [IRC] [Teaching & Learning] [Grading]
Current: [Assignment] [EBoard] [Lab] [Outline] [Partners] [Reading]
Sections: [Assignments] [EBoards] [Examples] [Handouts] [Labs] [Outlines] [Partners] [Readings]
Reference: [Setup] - [Functions A-Z] [Functions By Topic] - [Racket] [Scheme Report (R5RS)] [R6RS] [TSPL4]
Related Courses: [Davis (2013F)] [Rebelsky (2010F)] [Weinman (2012F)]
Misc: [SamR] [Glimmer Labs] [CS@Grinnell] [Grinnell] [Issue Tracker (Course)]
Samuel A. Rebelsky, rebelsky@grinnell.edu
Copyright (c) 2007-2013 Janet Davis, Samuel A. Rebelsky, and Jerod Weinman. (Selected materials are copyright by John David Stone or Henry Walker and are used with permission.)

This work is licensed under a Creative Commons Attribution 3.0 Unported License. To view a copy of this
license, visit http://creativecommons.org/licenses/by-nc/3.0/
or send a letter to Creative Commons, 543 Howard Street, 5th Floor,
San Francisco, California, 94105, USA.