Warning! Before attempting this lab, you should have set your basic DrScheme preferences as in the getting started in the MathLan lab.
You may also want to keep the corresponding reading at hand.
a. Convince DrScheme to compute the square root of 137641.
b. Verify that the value that DrScheme returns is indeed the square root of 137641. (Try squaring the value DrScheme gives you by hand.)
Ask DrScheme to subtract 68343 from 81722.
Tell DrScheme to multiply 162 by 1383.
Have DrScheme compute the absolute value of -197.
a. Ask DrScheme to compute the cube of 19 (that is, the result of raising 19 to the power 3).
b. Ask DrScheme to computer the nineteenth power of 3.
c. What do these results indicate about the relationship between procedures and arguments in Scheme?
Type each of the following expressions at the Scheme prompt and see what reaction you get.
You may wish to read the notes on this problem for an explanation of the results that you get.
a. Write a definition that will cause Scheme to recognize
as a name for the number 12.
b. Write a definition that will cause Scheme to recognize
raise-to-power as a synonym for
c. Use both names in expressions to verify that Scheme has understood them.
Copy the definitions you wrote for the preceding two exercises into the definitions window and execute them.
Save the definitions that you copied into the definitions window in
the previous exercise in a file named
(Conventionally, the names of files containing Scheme programs end in
a. Quit and restart DrScheme.
b. Determine whether
dozen is still defined. (It shouldn't be.)
c. See if you can figure out how to get DrScheme to reload your saved definitions.
Quit DrScheme and log out of the workstation.
(2 + 3)
When DrScheme sees the left parenthesis at the beginning of the expression
(2 + 3), it expects the expression to be a procedure call, and
it expects the procedure to be identified right after the left parenthesis.
2 does not identify a procedure; it stands for a number.
(A ``procedure application'' is the same thing as a procedure call.)
7 * 9
In the absence of parentheses, DrScheme sees
7 * 9 as three
separate and unrelated expressions -- the numeral
*, a name for the primitive multiplication procedure; and
9, another numeral. It interprets each of these as a command
to evaluate an expression: ``Compute the value of the numeral
7! Find out what the name
* stands for! Compute
the value of the numeral
9!'' So it performs the first of
these commands and displays
7; then it carries out the second
command, reporting that
* is the name of the primitive
*; and finally it carries out the third command and
displays the result,
9. This behavior is confusing, but it's
strictly logical if you look at it from the computer's point of view
(remembering, of course, that the computer has absolutely no common sense).
As in the preceding case, DrScheme sees
sqrt(49) as two
sqrt means ``Find out what
sqrt is!'' and
(49) means ``Call the procedure
49, with no arguments!'' DrScheme responds to the first
command by reporting that
sqrt is the primitive procedure for
computing square roots and to the second by pointing out that the number
49 is not a procedure.
August 23, 1997 (John David Stone)
March 17, 2000 (John David Stone)
29 August 2000 (Samuel A. Rebelsky)
30 August 2000 (Samuel A. Rebelsky)
Disclaimer Often, these pages were created "on the fly" with little, if any, proofreading. Any or all of the information on the pages may be incorrect. Please contact me if you notice errors.
This page may be found at http://www.cs.grinnell.edu/~rebelsky/Courses/CS151/2000F/Labs/beginning-scheme.html
Source text last modified Wed Sep 13 10:50:27 2000.
This page generated on Fri Sep 15 10:15:12 2000 by Siteweaver. Validate this page's HTML.
Contact our webmaster at email@example.com