Functional Problem Solving (CSC 151 2015F) : Outlines
Primary: [Front Door] [Schedule] - [Academic Honesty] [Disabilities] [Email] - [FAQ] [Teaching & Learning] [Grading] [Taking Notes] [Rubric] [Remote Access]
Current: [Assignment] [EBoard] [Lab] [Outline] [Reading]
Sections: [Assignments] [EBoards] [Labs] [Outlines] [Readings] - [Examples] [Handouts]
Reference: [Setup] [VM] [Errors] - [Functions A-Z] [Functions By Topic] - [Racket] [Scheme Report (R5RS)] [R6RS] [TSPL4]
Related Courses: [Curtsinger (2015F)] [Davis (2013F)] [Rebelsky (2015S)] [Weinman (2014F)]
Misc: [Submit Questions] - [SamR] [Glimmer Labs] [CS@Grinnell] [Grinnell] - [Issue Tracker (Course)]
Held: Wednesday, 9 September 2015
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
osectionIn 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)