(*^ ::[ Information = "This is a Mathematica Notebook file. It contains ASCII text, and can be transferred by email, ftp, or other text-file transfer utility. It should be read or edited using a copy of Mathematica or MathReader. If you received this as email, use your mail application or copy/paste to save everything from the line containing (*^ down to the line containing ^*) into a plain text file. On some systems you may have to give the file a name ending with ".ma" to allow Mathematica to recognize it as a Notebook. The line below identifies what version of Mathematica created this file, but it can be opened using any other version as well."; FrontEndVersion = "NeXT Mathematica Notebook Front End Version 2.2"; NeXTStandardFontEncoding; keywords = "BaseConvert, DefaultBase, StringToInt, numeralToInt"; fontset = title, inactive, noPageBreakBelow, noPageBreakInGroup, nohscroll, preserveAspect, groupLikeTitle, center, M7, bold, L1, e8, 24, "Times"; ; fontset = subtitle, inactive, noPageBreakBelow, noPageBreakInGroup, nohscroll, preserveAspect, groupLikeTitle, center, M7, bold, L1, e6, 18, "Times"; ; fontset = subsubtitle, inactive, noPageBreakBelow, noPageBreakInGroup, nohscroll, preserveAspect, groupLikeTitle, center, M7, italic, L1, e6, 14, "Times"; ; fontset = section, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeSection, grayBox, M22, bold, L1, a20, 18, "Times"; ; fontset = subsection, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeSection, blackBox, M19, bold, L1, a15, 14, "Times"; ; fontset = subsubsection, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeSection, whiteBox, M18, bold, L1, a12, 12, "Times"; ; fontset = text, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1, 12; fontset = smalltext, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1, 10, "Times"; ; fontset = input, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeInput, M42, N23, bold, L1, 12, "Courier"; ; fontset = output, output, inactive, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, L-5, 12, "Courier"; ; fontset = message, inactive, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, L1, 12, "Courier"; ; fontset = print, inactive, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, L1, 12, "Courier"; ; fontset = info, inactive, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, L1, 12, "Courier"; ; fontset = postscript, PostScript, formatAsPostScript, output, inactive, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeGraphics, M7, l34, w282, h287, L1, 12, "Courier"; ; fontset = name, inactive, noPageBreakInGroup, nohscroll, preserveAspect, M7, italic, B65535, L1, 10, "Times"; ; fontset = header, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, italic, L1, 12, "Times"; ; fontset = leftheader, 12; fontset = footer, inactive, nohscroll, noKeepOnOnePage, preserveAspect, center, M7, italic, L1, 12, "Times"; ; fontset = leftfooter, 12; fontset = help, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1, 12; fontset = clipboard, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1, 12; fontset = completions, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1, 12, "Courier"; ; fontset = special1, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1, 12; fontset = special2, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1, 12; fontset = special3, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1, 12; fontset = special4, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1, 12; fontset = special5, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1, 12; paletteColors = 128; automaticGrouping; currentKernel; ] :[font = title; inactive; preserveAspect; startGroup] Introduction to Programming with Mathematica ;[s] 2:0,0;35,1;46,-1; 2:1,21,16,Times,1,24,0,0,0;1,22,17,Times,3,24,0,0,0; :[font = subsubtitle; inactive; preserveAspect] By Richard J. Gaylord (gaylord@ux1.cso.uiuc.edu) Samuel N. Kamin (kamin@cs.uiuc.edu) Paul R. Wellin (wellin@sonoma.edu) :[font = subsubtitle; inactive; preserveAspect; plain; fontName = "Times"] Copyright ã 1993 by TELOS/Springer-Verlag ;[s] 3:0,0;10,1;11,2;41,-1; 3:1,13,10,Times,0,14,0,0,0;1,0,0,Symbol,0,14,0,0,0;1,13,10,Times,0,14,0,0,0; :[font = subtitle; inactive; preserveAspect; startGroup] Chapter 11 ± Contexts and Packages :[font = section; inactive; Cclosed; preserveAspect; startGroup] Functions defined in this Notebook...(page no. in book) :[font = text; inactive; preserveAspect; fontName = "Times"; endGroup] BaseConvert...273 DefaultBase...273 StringToInt...273 numeralToInt...273 :[font = section; inactive; Cclosed; preserveAspect; startGroup] Initialization (evaluate to turn off spell messages) :[font = input; initialization; preserveAspect] *) Off[General::spell] (* :[font = input; initialization; preserveAspect; endGroup] *) Off[General::spell1] (* :[font = section; inactive; Cclosed; preserveAspect; startGroup] Section 11.1 Using Packages :[font = input; preserveAspect] Needs["Calculus`VectorAnalysis`"] :[font = input; preserveAspect; endGroup] CrossProduct[{1.0, 2.0, 3.0}, {-1.0, -2.0, -3.0}] :[font = section; inactive; Cclosed; preserveAspect; startGroup; keywords = "BaseConvert, DefaultBase, StringToInt, numeralToInt"] Section 11.4 The BaseConvert Package :[font = input; preserveAspect] BeginPackage["BaseConvert`"] :[font = input; preserveAspect] DefaultBase::usage = "Default base used by StringToInt." :[font = input; preserveAspect] StringToInt::usage = "StringToInt[str, b] converts str to an integer, assuming it is written in base b. StringToInt[str] is equivalent to StringToInt[str, DefaultBase]." :[font = input; preserveAspect] Begin["`Private`"] :[font = input; preserveAspect] DefaultBase = 10; StringToInt[str_] := StringToInt[str, DefaultBase] StringToInt[str_String, b_Integer] := Which[ Not[2 <= b <= 10], Print["StringToInt: second argument is inappropriate base."], Not[Apply[And,Map[(0<=numeralToInt[#]