Functional Problem Solving (CSC 151 2015F) : Outlines

Outline 10: Side Effects: Output and Input


Held: Monday, 14 September 2015

Back to Outline 09 - Writing Your Own Procedures, Continued. On to Outline 11 - Documenting Programs and Procedures.

Summary

We consider sipmle textual interactive programs, programs that read input from the user and produce output.

Related Pages

Overview

Administrivia

Upcoming Work

Extra Credit Opportunities

Academic

Peer Support

Quiz 2 Returned

Problem 1

We expected something like the following.

(define cube (section expt <> 3))

Some of you tried to use *, but each <> is a separate input.

Problem 2a

(define fave (irgb 250 0 42))
(irgb-complement fave)
> (irgb->string fave)
"250/0/42"

This problem was to remind you that irgb-complement does not change fave. Rather, it computes a new color. That's similar to

(define num 5)
(square num)
> num
5

The behavior of irgb-complement and square contrasts a bit with the kinds of procedures we're playing with today.

Problem 2b

(define fave (irgb 250 0 42))
(define fave2 (irgb-darker (irgb-lighter fave)))
> (irgb->string fave2)
"239/0/42"

An important point from the labs was that irgb-lighter and irgb-darker cap when you reach the extreme values (0 and 255). So the red component of (irgb-lighter fave) is 255. When you subtract 16, we end up with 239.

Output

Using Output to Trace Program Behavior

Input

Side Effects