Functional Problem Solving (CSC 151 2016S) : Outlines
Primary: [Front Door] [Schedule] - [Academic Honesty] [Disabilities] [Email] - [FAQ] [Teaching & Learning] [Grading] [Taking Notes] [Rubric]
Current: [Assignment] [EBoard] [Lab] [Outline] [Reading]
Sections: [Assignments] [EBoards] [Labs] [Outlines] [Readings] - [Examples] [Handouts]
Reference: [Setup] [Remote] [VM] [Errors] - [Functions A-Z] [Functions By Topic] - [Racket] [Scheme Report (R5RS)] [R6RS] [TSPL4]
Related Courses: [Curtsinger (2016S)] [Davis (2013F)] [Rebelsky (2015F)] [Weinman (2014F)]
Misc: [SamR] [Glimmer Labs] [CS@Grinnell] [Grinnell] - [Issue Tracker (Course)]
Held: Friday, 5 February 2016
Back to Outline 07 - Transforming Images. On to Outline 09 - Writing Your Own Procedures, Continued.
Summary
We continue to consider how you can write your own procedures and why you might do so.
Related Pages
Overview
Administrivia
In Scheme, we often write compound expressions, expressions that include subexpressions.
(sqrt (+ (square x) (square y)))
Which is done first, square, +, or sqrt?
square
operations first, then the addition, then the sqrt.square operations is done first?
square
and +, or the DrFu procedures, such as
hshift-drawing.sqrtHow do you define your own procedures? Using the following template:
(define your-procedure (lambda (param1 ... paramn) expression1 ... expressionm))
For example,
(define square (lambda (val) (* val val)))
You can (and should) document your procedures so that others can understand what they are supposed to do. We'll come back to this issue soon.
define for each
parameter as the corresponding sent value.So (square 5) is a lot like
(define val 5) (* 5 5)