Computer Science Fundamentals (CS153 2003S)

Notes on Lab Writeup 01

Documenting

I like to run your programs to see what happens. Your output is much nicer if you include calls to display in the middle of your program.

You can, of course, create a separate testing file that includes those calls.

I also like to see the results of your tests included (but commented out).

Formatting

Try to avoid lines longer than eighty chararacters. They can be a pain for me if I print them or try to edit them.

Testing

Here's a fun little procedure that you can use to display the code for a test followed by the value of a test.

(define test
  (lambda (exp)
    (display exp)
    (newline)
    (eval exp)))

For example

> (test '(+ 1 2))
(+ 1 2)
3

Complex vs. Real Numbers

Many of you said complex numbers are not real. That statement is not precisely correct. The value 1 is complex and real (and rational and integral). A better statement would be complex numbers with an imaginary component are not real.

Defining Procedures

Many of you were fairly casual in your definitions of procedures. For example,

quotient finds the quotient of two values.

max finds the maximum value of its parameters.

But what does it mean to be a quotient or a maximum?

Here's a start for quotient:

For positive integers a and b, the quotient of a and b is the largest integer, q, such that q*a <= b.

Here'a start for max:

For non-complex numbers v1 ... vn, the maximum of those numbers is a vi such that vi >= vj for all j from 1 to n.

round

Many of you did not sufficiently test round. Note that

> (round 1.5)
2
> (round 2.5)
2

What does this suggest about round?

max

At least one of you noted the following interesting behavior of max. I thought I'd share it with the rest of you.

> (max 1.5 3/2)
1.5
> (max 3/2 1.5)
1.5

 

History

Monday, 3 February 2003 [Samuel A. Rebelsky]

 

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 Tue May 6 09:20:11 2003.
The source to the document was last modified on Mon Feb 3 09:35:22 2003.
This document may be found at http://www.cs.grinnell.edu/~rebelsky/Courses/CS153/2003S/Labs/writeup-notes.01.html.

You may wish to validate this document's HTML ; Valid CSS! ; Check with Bobby

Samuel A. Rebelsky, rebelsky@grinnell.edu