Fundamentals of CS I (CS151 2002F)
Primary:
[Skip To Body]
[Front Door]
[Current]
[Glance]
[Honesty]
[Instructions]
[Links]
[Search]
[Syllabus]
Groupings:
[Examples]
[Exams]
[Handouts]
[Homework]
[Labs]
[Outlines]
[Readings]
[Reference]
ECA:
[About]
[Grades]
[Quizzes]
[Submit Work]
[Change Password]
[Reset Password]
Miscellaenous:
[Scheme Reference]
[CS151 2002F Gum]
[CS151 2001S]
[SamR]
[Glimmer Labs]
[schemers.org]
Back to Simulation. On to Introduction to Files.
Held Tuesday, November 5, 2002
Summary
Today we investigate mechanisms for reading input in Scheme. We also revisit Scheme's primary mechanisms for generating output.
Assignments
Notes
;;; Procedure:
;;; merge-colors-1
;;; Parameters:
;;; color1, a color
;;; color2, a color
;;; Purpose:
;;; To merge color1 and color2 into a new color by using the red
;;; component of the first color, the green component of the second
;;; color, and the average blue component of the two colors.
;;; Produces:
;;; newcolor, the merged color
;;; Preconditions:
;;; Each color is a list of three integers in the range [0..255]
;;; The three integers represent red, green, and blue components of
;;; the color.
;;; Postconditions:
;;; newcolor is a list of three integers in the range [0..255]
;;;
(define merge-colors-1
(lambda (color1 color2)
(let ((red1 (car color1))
(red2 (car color2))
(green1 (cadr color1))
(green2 (cadr color2))
(blue1 (caddr color1))
(blue2 (caddr color2)))
(list red1 green2 (trunc (/ (+ blue1 blue2) 2))))))
Overview
write,
display,
and
newline.
read, which
reads one Scheme value, skipping whitespace as appropriate.
read-char, which reads a single character for input.
read is an interesting procedure. In many cases, it will
continue to read for more than one line.
Back to Simulation. On to Introduction to Files.
Primary:
[Skip To Body]
[Front Door]
[Current]
[Glance]
[Honesty]
[Instructions]
[Links]
[Search]
[Syllabus]
Groupings:
[Examples]
[Exams]
[Handouts]
[Homework]
[Labs]
[Outlines]
[Readings]
[Reference]
ECA:
[About]
[Grades]
[Quizzes]
[Submit Work]
[Change Password]
[Reset Password]
Miscellaenous:
[Scheme Reference]
[CS151 2002F Gum]
[CS151 2001S]
[SamR]
[Glimmer Labs]
[schemers.org]
Disclaimer:
I usually create these pages on the fly
, which means that I rarely
proofread them and they may contain bad grammar and incorrect details.
It also means that I tend to update them regularly (see the history for
more details). Feel free to contact me with any suggestions for changes.
This document was generated by
Siteweaver on Mon Dec 2 08:41:43 2002.
The source to the document was last modified on Tue Sep 3 23:13:32 2002.
This document may be found at http://www.cs.grinnell.edu/~rebelsky/Courses/CS151/2002F/Outlines/outline.35.html.
You may wish to
validate this document's HTML
;
;
Check with Bobby