(*********************************************************************** Mathematica-Compatible Notebook This notebook can be used on any computer system with Mathematica 3.0, MathReader 3.0, or any compatible application. The data for the notebook starts with the line of stars above. To get the notebook into a Mathematica-compatible application, do one of the following: * Save the data starting with the line of stars above into a file with a name ending in .nb, then open the file inside the application; * Copy the data starting with the line of stars above to the clipboard, then use the Paste menu command inside the application. Data for notebooks contains only printable 7-bit ASCII and can be sent directly in email or through ftp in text mode. Newlines can be CR, LF or CRLF (Unix, Macintosh or MS-DOS style). NOTE: If you modify the data for this notebook not in a Mathematica- compatible application, you must delete the line below containing the word CacheID, otherwise Mathematica-compatible applications may try to use invalid cache data. For more information on notebooks and Mathematica-compatible applications, contact Wolfram Research: web: http://www.wolfram.com email: info@wolfram.com phone: +1-217-398-0700 (U.S.) Notebook reader applications are available free of charge from Wolfram Research. ***********************************************************************) (*CacheID: 232*) (*NotebookFileLineBreakTest NotebookFileLineBreakTest*) (*NotebookOptionsPosition[ 5923, 214]*) (*NotebookOutlinePosition[ 7007, 249]*) (* CellTagsIndexPosition[ 6963, 245]*) (*WindowFrame->Normal*) Notebook[{ Cell[CellGroupData[{ Cell[TextData["18. Iterative Loops I: While: Problems"], "Title", Evaluatable->False, AspectRatioFixed->True], Cell["Last revision: March 23, 1998", "SmallText", Evaluatable->False, AspectRatioFixed->True], Cell[CellGroupData[{ Cell[TextData["Author: YourNameGoesHere"], "Subtitle", CellFrame->True, Evaluatable->False, AspectRatioFixed->True, Background->GrayLevel[0.899992]], Cell[CellGroupData[{ Cell["Even the Last", "Section", Evaluatable->False, AspectRatioFixed->True], Cell[TextData[{ StyleBox["Using \"", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Times", FontColor->GrayLevel[0]], StyleBox["While[]", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier", FontColor->GrayLevel[0]], StyleBox[ "\", define a function that finds the last even number in a list of \ numbers. (Make sure you handle the case of an empty list of numbers.)", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Times", FontColor->GrayLevel[0]] }], "Text", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Arial", FontColor->RGBColor[0.500008, 0, 0.500008]] }, Closed]], Cell[CellGroupData[{ Cell["iterFixedPointList", "Section", Evaluatable->False, AspectRatioFixed->True], Cell[TextData[{ StyleBox["Use \"", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Times", FontColor->GrayLevel[0]], StyleBox["While[]", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier", FontColor->GrayLevel[0]], StyleBox["\" to implement your own version of the function \"", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Times", FontColor->GrayLevel[0]], StyleBox["FixedPointList[]", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier", FontColor->GrayLevel[0]], StyleBox["\", called \"", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Times", FontColor->GrayLevel[0]], StyleBox["iterFixedPointList[]", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier", FontColor->GrayLevel[0]], StyleBox["\". Of course, don't use \"", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Times", FontColor->GrayLevel[0]], StyleBox["FixedPointList[]", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier", FontColor->GrayLevel[0]], StyleBox["\" in your definition..", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Times", FontColor->GrayLevel[0]] }], "Text", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Arial", FontColor->RGBColor[0.500008, 0, 0.500008]] }, Closed]], Cell[CellGroupData[{ Cell[TextData["Scoring a Random A"], "Section", Evaluatable->False, AspectRatioFixed->True], Cell[TextData[{ StyleBox[ "On average, how many random integers between 1 and 100 do you need to \ generate before you get one larger than 95? Use a \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["While[]", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox["\" construct to simulate this problem.", Evaluatable->False, AspectRatioFixed->True] }], "Text", Evaluatable->False, AspectRatioFixed->True] }, Closed]], Cell[CellGroupData[{ Cell[TextData["Recursion Reprise"], "Section", Evaluatable->False, AspectRatioFixed->True], Cell[TextData[{ StyleBox["Iteration (as in a \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["While[]", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox[ "\" loop) is an alternative to primarily list-based functional programming \ or recursion. Write a recursive version of \"", Evaluatable->False, AspectRatioFixed->True], StyleBox["firstNeg[]", Evaluatable->False, AspectRatioFixed->True, FontFamily->"Courier"], StyleBox["\". (A tail recursive version is preferred.)", Evaluatable->False, AspectRatioFixed->True] }], "Text", Evaluatable->False, AspectRatioFixed->True] }, Closed]] }, Open ]] }, Open ]] }, FrontEndVersion->"Macintosh 3.0", ScreenRectangle->{{0, 832}, {0, 604}}, WindowToolbars->{}, WindowSize->{520, 509}, WindowMargins->{{84, Automatic}, {Automatic, 1}}, PrintingCopies->1, PrintingPageRange->{1, Automatic}, PrivateNotebookOptions->{"ColorPalette"->{RGBColor, -1}}, ShowCellLabel->True, ShowCellTags->False, RenderingOptions->{"ObjectDithering"->True, "RasterDithering"->False}, MacintoshSystemPageSetup->"\<\ 00<0004/0B`000003809T?o>old" ] (*********************************************************************** Cached data follows. If you edit this Notebook file directly, not using Mathematica, you must remove the line containing CacheID at the top of the file. The cache data will then be recreated when you save this file from within Mathematica. ***********************************************************************) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[CellGroupData[{ Cell[1731, 51, 116, 2, 136, "Title", Evaluatable->False], Cell[1850, 55, 99, 2, 26, "SmallText", Evaluatable->False], Cell[CellGroupData[{ Cell[1974, 61, 156, 4, 78, "Subtitle", Evaluatable->False], Cell[CellGroupData[{ Cell[2155, 69, 80, 2, 50, "Section", Evaluatable->False], Cell[2238, 73, 668, 22, 47, "Text", Evaluatable->False] }, Closed]], Cell[CellGroupData[{ Cell[2943, 100, 85, 2, 30, "Section", Evaluatable->False], Cell[3031, 104, 1429, 50, 64, "Text", Evaluatable->False] }, Closed]], Cell[CellGroupData[{ Cell[4497, 159, 95, 2, 30, "Section", Evaluatable->False], Cell[4595, 163, 478, 15, 47, "Text", Evaluatable->False] }, Closed]], Cell[CellGroupData[{ Cell[5110, 183, 94, 2, 30, "Section", Evaluatable->False], Cell[5207, 187, 676, 22, 64, "Text", Evaluatable->False] }, Closed]] }, Open ]] }, Open ]] } ] *) (*********************************************************************** End of Mathematica Notebook file. ***********************************************************************)