{\rtf1\ansi\ansicpg1252\uc1 \deff0\deflang1033\deflangfe1033{\fonttbl{\f0\froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman{\*\falt Thorndale};}{\f1\fswiss\fcharset0\fprq2{\*\panose 020b0604020202020204}Arial;}
{\f2\fmodern\fcharset0\fprq1{\*\panose 02070309020205020404}Courier New;}{\f29\fswiss\fcharset128\fprq2{\*\panose 020b0604020202020204}Arial Unicode MS;}{\f30\fswiss\fcharset128\fprq2 @Arial Unicode MS;}
{\f31\froman\fcharset238\fprq2 Times New Roman CE{\*\falt Thorndale};}{\f32\froman\fcharset204\fprq2 Times New Roman Cyr{\*\falt Thorndale};}{\f34\froman\fcharset161\fprq2 Times New Roman Greek{\*\falt Thorndale};}
{\f35\froman\fcharset162\fprq2 Times New Roman Tur{\*\falt Thorndale};}{\f36\froman\fcharset177\fprq2 Times New Roman (Hebrew){\*\falt Thorndale};}{\f37\froman\fcharset178\fprq2 Times New Roman (Arabic){\*\falt Thorndale};}
{\f38\froman\fcharset186\fprq2 Times New Roman Baltic{\*\falt Thorndale};}{\f39\fswiss\fcharset238\fprq2 Arial CE;}{\f40\fswiss\fcharset204\fprq2 Arial Cyr;}{\f42\fswiss\fcharset161\fprq2 Arial Greek;}{\f43\fswiss\fcharset162\fprq2 Arial Tur;}
{\f44\fswiss\fcharset177\fprq2 Arial (Hebrew);}{\f45\fswiss\fcharset178\fprq2 Arial (Arabic);}{\f46\fswiss\fcharset186\fprq2 Arial Baltic;}{\f47\fmodern\fcharset238\fprq1 Courier New CE;}{\f48\fmodern\fcharset204\fprq1 Courier New Cyr;}
{\f50\fmodern\fcharset161\fprq1 Courier New Greek;}{\f51\fmodern\fcharset162\fprq1 Courier New Tur;}{\f52\fmodern\fcharset177\fprq1 Courier New (Hebrew);}{\f53\fmodern\fcharset178\fprq1 Courier New (Arabic);}
{\f54\fmodern\fcharset186\fprq1 Courier New Baltic;}{\f265\fswiss\fcharset0\fprq2 Arial Unicode MS Western;}{\f263\fswiss\fcharset238\fprq2 Arial Unicode MS CE;}{\f264\fswiss\fcharset204\fprq2 Arial Unicode MS Cyr;}
{\f266\fswiss\fcharset161\fprq2 Arial Unicode MS Greek;}{\f267\fswiss\fcharset162\fprq2 Arial Unicode MS Tur;}{\f268\fswiss\fcharset177\fprq2 Arial Unicode MS (Hebrew);}{\f269\fswiss\fcharset178\fprq2 Arial Unicode MS (Arabic);}
{\f270\fswiss\fcharset186\fprq2 Arial Unicode MS Baltic;}{\f273\fswiss\fcharset0\fprq2 @Arial Unicode MS Western;}{\f271\fswiss\fcharset238\fprq2 @Arial Unicode MS CE;}{\f272\fswiss\fcharset204\fprq2 @Arial Unicode MS Cyr;}
{\f274\fswiss\fcharset161\fprq2 @Arial Unicode MS Greek;}{\f275\fswiss\fcharset162\fprq2 @Arial Unicode MS Tur;}{\f276\fswiss\fcharset177\fprq2 @Arial Unicode MS (Hebrew);}{\f277\fswiss\fcharset178\fprq2 @Arial Unicode MS (Arabic);}
{\f278\fswiss\fcharset186\fprq2 @Arial Unicode MS Baltic;}}{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;
\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;\red128\green0\blue128;\red128\green0\blue0;\red128\green128\blue0;\red128\green128\blue128;\red192\green192\blue192;}{\stylesheet{\ql \li0\ri0\nowidctlpar\faauto\rin0\lin0\itap0 
\fs24\cf1\lang1033\langfe255\cgrid\langnp1033\langfenp255 \snext0 Normal;}{\s1\ql \li0\ri0\sb240\sa60\keepn\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 \b\fs28\cf1\lang1033\langfe255\loch\f1\hich\af0\dbch\af0\cgrid\langnp1033\langfenp255 
\sbasedon15 \snext15 heading 1;}{\s2\ql \li0\ri0\keepn\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 \b\fs20\cf1\lang1033\langfe255\cgrid\langnp1033\langfenp255 \sbasedon0 \snext0 heading 2;}{\*\cs10 \additive Default Paragraph Font;}{
\s15\ql \li0\ri0\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 \fs20\cf1\lang1033\langfe255\cgrid\langnp1033\langfenp255 \snext15 Default;}{\s16\ql \li0\ri0\sa120\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 
\fs20\cf1\lang1033\langfe255\cgrid\langnp1033\langfenp255 \sbasedon15 \snext16 Text body;}{\s17\ql \li0\ri0\sb240\sa120\keepn\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 \fs28\cf1\lang1033\langfe255\loch\f1\hich\af0\dbch\af0\cgrid\langnp1033\langfenp255 
\sbasedon15 \snext16 Heading;}{\s18\ql \fi-360\li360\ri0\nowidctlpar\aspalpha\faauto\rin0\lin360\itap0 \fs20\cf1\lang1033\langfe255\cgrid\langnp1033\langfenp255 \sbasedon15 \snext18 List;}{
\s19\ql \fi-360\li720\ri0\nowidctlpar\aspalpha\faauto\rin0\lin720\itap0 \fs20\cf1\lang1033\langfe255\cgrid\langnp1033\langfenp255 \sbasedon15 \snext19 List 2;}{\s20\ql \li0\ri0\nowidctlpar\tqc\tx4320\tqr\tx8640\aspalpha\faauto\rin0\lin0\itap0 
\fs20\cf1\lang1033\langfe255\cgrid\langnp1033\langfenp255 \sbasedon15 \snext20 header;}{\s21\ql \li0\ri0\nowidctlpar\tqc\tx4320\tqr\tx8640\aspalpha\faauto\rin0\lin0\itap0 \fs20\cf1\lang1033\langfe255\cgrid\langnp1033\langfenp255 \sbasedon15 \snext21 
footer;}{\s22\ql \li0\ri0\sa120\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 \fs20\cf1\lang1033\langfe255\cgrid\langnp1033\langfenp255 \sbasedon16 \snext22 Table Contents;}{\s23\qc \li0\ri0\sa120\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 
\b\i\fs20\cf1\lang1033\langfe255\cgrid\langnp1033\langfenp255 \sbasedon22 \snext23 Table Heading;}{\s24\ql \li0\ri0\sb120\sa120\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 \i\fs20\cf1\lang1033\langfe255\cgrid\langnp1033\langfenp255 \sbasedon15 \snext24 
caption;}{\s25\ql \li0\ri0\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 \fs20\cf1\lang1033\langfe255\cgrid\langnp1033\langfenp255 \sbasedon15 \snext25 Index;}{\s26\qc \li0\ri0\sb240\sa60\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 
\b\fs32\cf1\lang1033\langfe255\loch\f1\hich\af0\dbch\af0\cgrid\langnp1033\langfenp255 \sbasedon15 \snext27 Title;}{\s27\qc \li0\ri0\sa60\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 
\fs24\cf1\lang1033\langfe255\loch\f1\hich\af0\dbch\af0\cgrid\langnp1033\langfenp255 \sbasedon15 \snext16 Subtitle;}{\*\cs28 \additive \fs24\cf1\lang0\langfe255\langfenp255 Numbering Symbols;}{\*\cs29 \additive \fs24\cf1\lang0\langfe255\langfenp255 
WW-Default Paragraph Font;}{\*\cs30 \additive \fs24\cf1\lang0\langfe255\langfenp255 \sbasedon29 page number;}}{\info{\title hw04 - cs131 - f02}{\author CNRS}{\operator CNRS}{\creatim\yr2001\mo6\dy25\hr10\min4}{\revtim\yr2002\mo9\dy16\hr23\min22}
{\printim\yr2002\mo8\dy29\hr18\min43}{\version3}{\edmins1}{\nofpages2}{\nofwords893}{\nofchars5091}{\*\company CNRS-HSU}{\nofcharsws6252}{\vern8269}}\margl1440\margr1440\margt1400\margb720 
\widowctrl\ftnbj\aenddoc\noxlattoyen\expshrtn\noultrlspc\dntblnsbdb\nospaceforul\hyphcaps0\horzdoc\dghspace120\dgvspace120\dghorigin1701\dgvorigin1984\dghshow0\dgvshow3\jcompress\viewkind1\viewscale90\nolnhtadjtbl \fet0\sectd 
\sbknone\linex0\headery709\sectdefaultcl {\header \pard\plain \s20\ql \li0\ri0\nowidctlpar\tqc\tx4320\tqr\tx8640\aspalpha\faauto\rin0\lin0\itap0 \fs20\cf1\lang1033\langfe255\cgrid\langnp1033\langfenp255 {\fs16 CS 131 - Homework #4\tab \tab p. }
{\field{\*\fldinst {\cs30\fs16  PAGE }}{\fldrslt {\cs30\fs16\lang1024\langfe1024\noproof 2}}}{\field{\*\fldinst {\\page\\* ARABIC}}{\fldrslt {2}}}{
\par }{\fs16 Fall 2002
\par }}{\*\pnseclvl1\pnucrm\pnstart1\pnindent720\pnhang{\pntxta .}}{\*\pnseclvl2\pnucltr\pnstart1\pnindent720\pnhang{\pntxta .}}{\*\pnseclvl3\pndec\pnstart1\pnindent720\pnhang{\pntxta .}}{\*\pnseclvl4\pnlcltr\pnstart1\pnindent720\pnhang{\pntxta )}}
{\*\pnseclvl5\pndec\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}{\*\pnseclvl6\pnlcltr\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}{\*\pnseclvl7\pnlcrm\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}{\*\pnseclvl8
\pnlcltr\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}{\*\pnseclvl9\pnlcrm\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}\pard\plain \s15\qc \li0\ri0\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 
\fs20\cf1\lang1033\langfe255\cgrid\langnp1033\langfenp255 {\b CS 131 - Intro to Computer Science I - Fall 2002
\par Homework #4
\par DUE: Tuesday, September 24th, }{\b\ul Beginning}{\b  of Lecture
\par }\pard \s15\ql \li0\ri0\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 {
\par You may work in pairs on this assignment, or individually. Please note, however, the following requirements if you work in a pair:
\par }\pard \s15\ql \fi-435\li855\ri0\nowidctlpar\aspalpha\faauto\rin0\lin855\itap0 {*\tab You must do the whole assignment }{\i together}{, as a pair (you may not split up the parts, do them individually, and then turn in the combination, for example.)
\par *\tab By working in a pair, I mean that both of you are sitting at the }{\i same}{ computer, with one typing ("driving") and the other suggesting/reading over what has been done and what should be done next ("navigating"). The driver 
and navigator should SWITCH roles about every half hour.
\par *\tab If you do this, you turn in a single copy of the assignment with both of your names on the first line.
\par 
\par }\pard \s15\ql \li0\ri0\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 {As before, you will turn in certain function definitions and expressions that you have typed into the DrScheme definitions window and saved into a file name ending in }{\b .scm}{ .}{

\par 
\par Here is the }{\b program recipe}{ template in effect for this homework --- it is also available from the course web page, for cut-and-paste purposes. All identifiers (function names
, parameters, and variables) are expected to be meaningful, and function code should proceed from how you think about the problem.
\par 
\par }{\b\loch\af2 \hich\af0\dbch\af0\loch\f2 at the beginning of the homework file:
\par }{\loch\af2 \hich\af0\dbch\af0\loch\f2 ;**************************************************************************
\par \hich\af0\dbch\af0\loch\f2 ; type in\hich\af0\dbch\af0\loch\f2  your name (or both names, IF working as a pair)
\par \hich\af0\dbch\af0\loch\f2 ; CS 131 HW X
\par \hich\af0\dbch\af0\loch\f2 ;**************************************************************************
\par 
\par }{\b\loch\af2 \hich\af0\dbch\af0\loch\f2 ...for each problem on the homework:
\par }{\loch\af2 \hich\af0\dbch\af0\loch\f2 ;**************************************************************************
\par \hich\af0\dbch\af0\loch\f2 ; P\hich\af0\dbch\af0\loch\f2 roblem X
\par \hich\af0\dbch\af0\loch\f2 ;
\par 
\par }{\b\loch\af2 \hich\af0\dbch\af0\loch\f2 ...to be done for EACH function (auxiliary OR main):
\par }{\loch\af2 \hich\af0\dbch\af0\loch\f2 ;;--------------------------------------------------------------------------
\par \hich\af0\dbch\af0\loch\f2 ;; CONTRACT: function-name : input types -> output types
\par 
\par \hich\af0\dbch\af0\loch\f2 ;; PURPOSE: type in PURPOSE STATEMENT for function-name, making
\par \hich\af0\dbch\af0\loch\f2 ;; use of parameter names from header/definition
\par 
\par \hich\af0\dbch\af0\loch\f2 ;; EXAMPLES:
\par \hich\af0\dbch\af0\loch\f2 ;; (function-name specific-arguments) should produce actual-value
\par \hich\af0\dbch\af0\loch\f2 ;;    (how many examples? We'll refine this --- but, for now, t\hich\af0\dbch\af0\loch\f2 ry to 
\par \hich\af0\dbch\af0\loch\f2 ;;    have one for each main "category" of data that might occur,
\par \hich\af0\dbch\af0\loch\f2 ;;    plus "boundary" situations.)
\par 
\par \hich\af0\dbch\af0\loch\f2 (define (function-name parameter-names)
\par \hich\af0\dbch\af0\loch\f2    ; expr for function-name's body, indented. BUT final parenth can be here: )
\par \hich\af0\dbch\af0\loch\f2 ) ; ...or here.
\par 
\par \hich\af0\dbch\af0\loch\f2 ;; TESTS:
\par \hich\af0\dbch\af0\loch\f2 ;\hich\af0\dbch\af0\loch\f2  type in your specific tests (from examples above) here. 
\par \hich\af0\dbch\af0\loch\f2 ; you may choose to compare your function call result to your expected 
\par \hich\af0\dbch\af0\loch\f2 ; result, as in:
\par \hich\af0\dbch\af0\loch\f2 (= (function-name actual-arguments)
\par \hich\af0\dbch\af0\loch\f2    expected-result)
\par \hich\af0\dbch\af0\loch\f2 ; or, you may type so both will show on consecutive l\hich\af0\dbch\af0\loch\f2 ines:
\par \hich\af0\dbch\af0\loch\f2 (function-name actual-arguments)
\par \hich\af0\dbch\af0\loch\f2 ; expected result
\par \hich\af0\dbch\af0\loch\f2 expected-result
\par \hich\af0\dbch\af0\loch\f2 ; (and these two styles may be mixed and matched as needed, as long
\par \hich\af0\dbch\af0\loch\f2 ; as all examples are actually run as tests)
\par \hich\af0\dbch\af0\loch\f2 ;---------------------------------------------------------------------\hich\af0\dbch\af0\loch\f2 ------
\par }{
\par A few more requirements:
\par }\pard \s15\ql \fi-435\li420\ri0\nowidctlpar\aspalpha\faauto\rin0\lin420\itap0 {*\tab choose meaningful function, parameter, and variable names.
\par *\tab use auxiliary functions as they are appropriate.
\par *\tab reuse functions whenever possible and appropriate. If a function has already been defined for a previous problem within the same definitions file, you may simply use it in a later problem's function.
\par *\tab define constant values in your functions as named variables written in all capital letters; for example,
\par }{\loch\af2 \tab \hich\af0\dbch\af0\loch\f2 (define CRUST-WIDTH 1)
\par 
\par }{1.\tab Do exercise 5.1.2 on p. 49 in "How to Design Programs". After doing the "normal" tests called for in the design recipe, test the function}{\b  check-guess}{
  further by playing the game as described in the textbook. (Just include the specified call in your  definitions file, after your "normal" design recipe tests; I'll just have to trust that you tried it out, and that it worked... 8-) )
\par 
\par 2.\tab Do exercises 6.2.2 on p. 56 and 6.2.3 and 6.2.4 on p. 57. (I hope it is clear that 6.2.4 had better use the results of 6.2.2 and 
6.2.3...!) Precede your code with the contents of Figure 8 on p. 57 (including a comment attributing the source of that code, of course...)
\par }\pard \s15\ql \li0\ri0\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 {
\par }\pard \s15\ql \fi-435\li420\ri0\nowidctlpar\aspalpha\faauto\rin0\lin420\itap0 {3.\tab (Adapted from Keith Cooper's section of Rice University's COMP 210, Spring 2002)
\par \tab Manipulating Cartesian Coordinates
\par 
\par \tab In the text is developed the notion of a point in a two-dimensional space. We can develop an equivalent notion for a point in a three-dimensional space. For historical reasons, we will call the coordinates }{\i x}{, }{\i y}{, and }{\i z}{\b\i  }{
(these names are traditional, and considered readable within this scenario).
\par 
\par }\pard \s15\ql \fi-435\li855\ri0\nowidctlpar\aspalpha\faauto\rin0\lin855\itap0 {a)\tab Develop a data definition for points in 3-space, and define the structure so defined; call the resulting structure }{\b point3}{
. (A data definition is documentation of the form:
\par }{\loch\af2 \hich\af0\dbch\af0\loch\f2 ;; a my-new-struct is a structure:
\par \hich\af0\dbch\af0\loch\f2 ;;     (make-my-new-struct info-1 info-2 ... info-n)
\par \hich\af0\dbch\af0\loch\f2 ;; ...where info-1 is a data-type and info-2 is a data-type ... 
\par \hich\af0\dbch\af0\loch\f2 ;; and info-n is a data-type
\par 
\par \tab }{Modifying the example in the text on p. 64, for a structure}{\b  star}{:}{\loch\af2 
\par }{\b\loch\af2 
\par }{\loch\af2 \hich\af0\dbch\af0\loch\f2 ;; a star is a structure:}{\b\loch\af2 
\par }{\loch\af2 \hich\af0\dbch\af0\loch\f2 ;;     (make-\hich\af0\dbch\af0\loch\f2 star last first instrument sales)
\par \hich\af0\dbch\af0\loch\f2 ;; ...where last, first, and instrument are symbols 
\par \hich\af0\dbch\af0\loch\f2 ;; and sales is a number
\par 
\par \tab }{You should place the data definition for }{\b point3 }{before its define-struct statement in your definitions file.}{\loch\af2 
\par }{
\par b)\tab Write a program, }{\b point3-add}{, that consumes two }{\b point3}{ instances and returns a }{\b point3}{ instance whose coordinates are the }{\b sum }{of the coordinates of the two }{\b point3}{ arguments.
\par 
\par c)\tab Write a program }{\b distance }{that consumes two }{\b point3 }{instances and produces the distance between two points. 
\par 
\par Note that, as you designing and writing the above programs, your programs may be easier to read (and to write) if you develop several helper functions for subtasks in the computation. You should do so as appropriate, of course.
\par Also note that the Scheme function }{\b sqrt : number -> number }{computes the square root of a given number. If you need additional information on geometry, consult one of the standard references (or a careful Google search, etc.)
\par }\pard \s15\ql \fi-435\li420\ri0\nowidctlpar\aspalpha\faauto\rin0\lin420\itap0 {
\par }\pard \s15\ql \fi-435\li450\ri0\nowidctlpar\aspalpha\faauto\rin0\lin450\itap0 {When you are done with problems 1-3, save your definitions window contents using the "Save Definitions" command under the File menu. E-mail the contents of this saved file to 
}{\b st10@humboldt.edu}{, either by cut-and-paste or attachment or whatever is easiest for you. Make the subject line of your message }{\b 131hw04}{. }{
\par }}