{\rtf1\ansi\ansicpg1252\uc1 \deff0\deflang1033\deflangfe1033{\fonttbl{\f0\froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman{\*\falt Thorndale};}{\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};}
{\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\widctlpar\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \fs24\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 \snext0 Normal;}{\*\cs10 \additive Default Paragraph Font;}{
\s15\ql \li0\ri0\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 \fs24\cf1\lang1033\langfe255\cgrid\langnp1033\langfenp255 \snext15 Default;}{\s16\ql \li0\ri0\nowidctlpar\tqc\tx4320\tqr\tx8640\aspalpha\faauto\rin0\lin0\itap0 
\fs24\cf1\lang1033\langfe255\cgrid\langnp1033\langfenp255 \sbasedon15 \snext16 header;}{\*\cs17 \additive \fs24\cf1\lang0\langfe255\langfenp255 Numbering Symbols;}}{\info{\author Sharon Tuttle}{\operator CNRS}{\creatim\yr2002\mo10\dy11\hr14\min30}
{\revtim\yr2002\mo10\dy18\hr15\min6}{\printim\yr2113\mo1\dy1}{\version7}{\edmins3}{\nofpages2}{\nofwords583}{\nofchars3328}{\*\company CNRS-HSU}{\nofcharsws4087}{\vern8269}}\margt2079 
\deftab1250\widowctrl\ftnbj\aenddoc\noxlattoyen\expshrtn\noultrlspc\dntblnsbdb\nospaceforul\hyphcaps0\horzdoc\dghspace120\dgvspace120\dghorigin1701\dgvorigin1984\dghshow0\dgvshow3\jcompress\viewkind1\viewscale84\viewzk2\nolnhtadjtbl \fet0\sectd 
\sbknone\linex0\headery1440\sectdefaultcl {\header \pard\plain \s16\ql \li0\ri0\nowidctlpar\tqc\tx4320\tqr\tx8640\aspalpha\faauto\rin0\lin0\itap0 \fs24\cf1\lang1033\langfe255\cgrid\langnp1033\langfenp255 {\fs16 CS 131 - Homework #7\tab \tab p. }
{\field{\*\fldinst {\fs16 \\page}}{\fldrslt {\fs16\lang1024\langfe1024\noproof 1}}}{
\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 
\fs24\cf1\lang1033\langfe255\cgrid\langnp1033\langfenp255 {\b\fs20 CS 131 - Intro to Computer Science I - Fall 2002
\par Homework #7
\par DUE: Friday, October 25th, by }{\b\fs20\ul 5:00 pm}{\b\fs20 
\par }{\b\fs20\ul 
\par }\pard \s15\ql \li0\ri0\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 {\fs20 As always, you will turn in certain function definitions and expressions that you have typed into the DrScheme definitions window and saved into one or more file names ending in }{
\b\fs20 .scm}{\fs20  .
\par 
\par The program recipe in effect for this homework is the }{\b\fs20 10-11 version}{\fs20 , w
hich now requires a brief description at the end of each data definition (especially for structures, and if the meaning is not clear for "supertype"-style and list-style data definitions). Please let me know if you have any questions about this latest pro
gram recipe version.
\par 
\par The same general class style guidelines still apply, also:
\par }\pard \s15\ql \fi-435\li420\ri0\nowidctlpar\aspalpha\faauto\rin0\lin420\itap0 {\fs20 *\tab choose meaningful function, parameter, and variable names.
\par *\tab use auxiliary functions whenever 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 \tab (define CRUST-WIDTH 1)
\par *\tab a data definition is not repeated for every function that uses that data; the data definition is only given once in a particular Scheme file. The template for that data definition only has to appear once, as well; HOWEVER, if you find 
it helpful, you may repeat that template before each appropriate function body for which you find that template useful.
\par 
\par In particular: please note that a problem may ask you to write a particular function. When it is appropriate, you should also write unspecified auxiliary functions that you decide are useful in writing the specifically-requested function.
\par 
\par 1.\tab Programs that return lists
\par }\pard \s15\ql \fi-435\li855\ri0\nowidctlpar\aspalpha\faauto\rin0\lin855\itap0 {\fs20 (a)\tab Write a function }{\b\fs20 positive-elements}{\fs20  that consumes a list of numbers and returns a list containing those elements of the list that are positive.

\par 
\par (b)\tab Write a function }{\b\fs20 even-positions}{\fs20  that consumes a list a returns those elements in even-numbered positions in the list --- that is, the second element, the fourth element, the sixth element, and so on.
\par 
\par }\pard \s15\ql \fi-435\li420\ri0\nowidctlpar\aspalpha\faauto\rin0\lin420\itap0 {\fs20 2.\tab More programs that return lists
\par }\pard \s15\ql \fi-435\li855\ri0\nowidctlpar\aspalpha\faauto\rin0\lin855\itap0 {\fs20 (a)\tab Do exercise 10.1.5 on p. 141 of \'93How to Design Programs (HtDP)\'94. However, call the function }{\b\fs20 eliminate-exp1}{\fs20 .
\par }\pard \s15\ql \fi-435\li420\ri0\nowidctlpar\aspalpha\faauto\rin0\lin420\itap0 {\fs20 
\par }\pard \s15\ql \fi-435\li855\ri0\nowidctlpar\aspalpha\faauto\rin0\lin855\itap0 {\fs20 (b)\tab Do exercise 10.1.6 on p. 141 of \'93How to Design Programs (HtDP)\'94, except that you only have to write the function substitute (you do not
 need to write/turn in function name-robot), instead giving it the name }{\b\fs20 substitute1}{\fs20 .
\par 
\par (c)\tab Do exercise 10.1.7 on p. 141 of \'93How to Design Programs (HtDP)\'94, but call the function }{\b\fs20 recall1}{\fs20 .
\par 
\par }\pard \s15\ql \fi-435\li420\ri0\nowidctlpar\aspalpha\faauto\rin0\lin420\itap0 {\fs20 3.\tab Consider what you just did on problem #2. Now, we instead have the concept of a toy that includes its name (a symbol), its p
rice, and its quantity on hand, and we have lists of such toys.
\par }\pard \s15\ql \fi-435\li855\ri0\nowidctlpar\aspalpha\faauto\rin0\lin855\itap0 {\fs20 (a)\tab Do exercise 10.2.1, except do it for a list of toys as described above, and you only have to write the function }{\b\fs20 contains?}{\fs20 
 (you do not need to write the function contains-doll?)
\par 
\par (b)\tab Do exercise 10.2.3 on p. 146.
\par 
\par (c)\tab Define a function }{\b\fs20 which-are-low}{\fs20  that takes a quantity, and then returns a list of the names of all toys whose quantity is equal to or  below the quantity given. (For example, if the quantity given
 is 5, it would return the names of all toys whose quantity is 5 or fewer.)
\par 
\par (d)\tab develop the function }{\b\fs20 change-prices}{\fs20 , which takes a list of such toys and a percentage, and if the percentage is positive then it produces a new list of toys with all of the prices raised
 by that percentage, and if the percentage is negative then it produces a new list of toys with all of the prices lowered by that percentage.
\par 
\par (e) \tab redo 10.1.5 for a list of such toys. (Call the function }{\b\fs20 eliminate-exp2}{\fs20 .)
\par 
\par (f)\tab redo 10.1.6 for a list of such toys (but you only have to write }{\b\fs20 substitute2}{\fs20 ).
\par 
\par (g)\tab redo 10.1.7 for a list of such toys (but you only have to write }{\b\fs20 recall2}{\fs20 ).
\par 
\par }\pard \s15\ql \fi-435\li420\ri0\nowidctlpar\aspalpha\faauto\rin0\lin420\itap0 {\fs20 4.\tab Develop a function }{\b\fs20 in-both}{\fs20  that takes in two lists of symbols, and produces a list of the symbols that are in both lists. (Hint: use function }{
\b\fs20 contains-symbol?}{\fs20  from the in-class examples to help you.)
\par }\pard \s15\qc \li0\ri0\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 {\ul 
\par }\pard \s15\ql \li0\ri0\nowidctlpar\aspalpha\faauto\rin0\lin0\itap0 {
\par }{\loch\af2 
\par }\pard \s15\ql \fi-435\li420\ri0\nowidctlpar\aspalpha\faauto\rin0\lin420\itap0 {\loch\af2 
\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 {
\par }}