Functional Problem Solving (CSC 151 2013F) : Reference
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)]
Believe it or not, but every list operation (more or less) can be defined in terms of these five basic operations.
null
(cons
value
lst)
value
to the front of lst.
(cdr
lst)
lst but without
the first element. (car
lst)
lst.
(null?
lst)
lst is the empty list.
(list
val_0
val_1 ...
val_n)
n+1 of the form
(val_0 val_1
... val_n).
(make-list
n
val)
n
copies of val.
(list-drop
lst
n)
n elements of lst.
(list-take
lst
n)
n elements of lst.
(for-each
proc!
lst)
proc! to each element of the
given list. Called primarily for side effects.
(map
func
lst)
func to the corresponding element of
lst.
Most of these are forthcoming.
(list-ref
lst
n)
nth element of
lst. Note that elements are numbered
starting at 0.
(reverse
lst)
lst, but in the opposite order.
car and cdr(caar
lst)
lst's first element is a list,
gets the first element of that first element, the
the car of the car
of lst. If
lst is not a list, or its first element
is not a list, reports an error.
(cadr
lst)
lst,
the car of the cdr
of lst(cddr
lst)
lst,
the cdr of the cdr
of lst(caddr
lst)
lst,
the car of the cdr
of the cdr
of lst.
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.