RE: Static variables
- To: mathgroup at smc.vnet.net
- Subject: [mg9386] RE: [mg9287] Static variables
- From: jmthomas <jmthomas at cybercable.tm.fr>
- Date: Sun, 2 Nov 1997 01:02:18 -0500
- Sender: owner-wri-mathgroup at wolfram.com
I've tried the two solutions to your problem, the one given by Sean Roos = (building of a package), and the one by Hein Hundal (module) Since modules are (much!) shorter to write and to handle, it seems this is the solution to your problem. Anyway, passing through a package somehow mimics the C programming langage. It should be easier to maintain a program with such variables if they are defined in packages. Hope this helps. (*********************************************************************** 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 at 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[ 6339, 229]*) (*NotebookOutlinePosition[ 30086, 1091]*) (* CellTagsIndexPosition[ 30042, 1087]*) (*WindowFrame->Normal*) Notebook[{ Cell[TextData[{ StyleBox[ "Jean-Marie THOMAS\tConseil et Audit en Ing\[EAcute]nierie de Calcul", FontSize->24], "\n\n5, rue de l'Ecurie\t67000 STRASBOURG\tFrance\n\nphone (+33) 03 88 = 32 \ 93 64\tmailto: = jmthomas at cybercable.tm.fr\n\nwww.cybercable.tm.fr/~jmthomas" }], "Text", CellFrame->True, TextAlignment->Center, FontFamily->"Garamond", FontSize->16, Background->GrayLevel[0.849989]], Cell[CellGroupData[{ Cell["First approach: modules", "Title"], Cell[CellGroupData[{ Cell["From MathGroup, nov 1st 1997", "Section"], Cell["\<\ Try wrapping your function in a module with the required static variables. Below staticSum is static and local to the function cumaulativesum.\ \>", "SmallText"], Cell[TextData[{ StyleBox[ "Module[{staticSum},\n staticSum = 0;\n cumulativesum[x_] := = staticSum \ += x ]\n\nTable[cumulativesum[i], {i,10}]", FontFamily->"Courier", FontWeight->"Bold"], "\n" }], "Text", Evaluatable->True], Cell["\<\ Hein Hundal send replies to hundal at vicon.net\ \>", "SmallText"] }, Open ]], Cell[CellGroupData[{ Cell["My analysis:", "Section"], Cell["\<\ This technique does meet the requirement: the value of staticSum still = \ exists after the module has been run.\ \>", "Text"], Cell[BoxData[ \(Table[cumulativesum[i], {i, 2}] // Trace\)], "Input"], Cell[BoxData[ \(Table[cumulativesum[i], {i, 2}] // Trace\)], "Input"], Cell["\<\ But you need a function to be included inside the module to modify the = static \ variable:\ \>", "Text"], Cell[BoxData[ RowBox[{ StyleBox["Module", FontFamily->"Courier", FontWeight->"Bold"], StyleBox["[", FontFamily->"Courier", FontWeight->"Bold"], RowBox[{ StyleBox[\({staticSum}\), FontFamily->"Courier", FontWeight->"Bold"], StyleBox[",", FontFamily->"Courier", FontWeight->"Bold"], StyleBox["\n", FontFamily->"Courier", FontWeight->"Bold"], StyleBox[" ", FontFamily->"Courier", FontWeight->"Bold"], RowBox[{ StyleBox[\(staticSum\ = \ 0\), FontFamily->"Courier", FontWeight->"Bold"], StyleBox[";", FontFamily->"Courier", FontWeight->"Bold"], StyleBox["\n", FontFamily->"Courier", FontWeight->"Bold"], StyleBox[" ", FontFamily->"Courier", FontWeight->"Bold"], StyleBox[\(cumulativeSum[x_]\ := \ staticSum\ += \ x\), FontFamily->"Courier", FontWeight->"Bold"], StyleBox[" ", FontFamily->"Courier", FontWeight->"Bold"], StyleBox[";", FontFamily->"Courier", FontWeight->"Bold"], "\n", \(resetStaticSum[value_] := \(staticSum = value\)\)}]}], = "\n", "]"}]], "Input"], Cell[BoxData[ \(cumulativeSum[1]\)], "Input"], Cell[BoxData[ \(cumulativeSum[1]\)], "Input"], Cell[BoxData[ \(resetStaticSum[0]\)], "Input"], Cell[BoxData[ \(cumulativeSum[1]\)], "Input"], Cell["The value of staticSum is hidden:", "Text"], Cell[BoxData[ \(?? staticSum\)], "Input"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["Second approach: package", "Title"], Cell[CellGroupData[{ Cell["a package doing the same thing", "Section"], Cell[BoxData[{ \(BeginPackage["\<staticVariable`\>"]\), \(showStaticVariable::usage = "\<showStaticVariable prints the value of myStaticVariable.\>"\), \(setStaticVariable::usage = "\<setStaticVariable[newValue_] sets myStaticVariable to = newValue.\>"\), \(addToStaticVariable::usage = "\<addToStaticVariable[aValue] adds aValue to = upData[{ Cell["Notebook Options", "Section"], Cell["\<\ The options defined for the style below will be used at the Notebook = level.\ \>", "Text"], Cell[StyleData["Notebook"], PageHeaders->{{Cell[ TextData[ { CounterBox[ "Page"]}], "PageNumber"], None, Cell[ TextData[ { ValueBox[ "FileName"]}], "Header"]}, {Cell[ TextData[ { ValueBox[ "FileName"]}], "Header"], None, Cell[ TextData[ { CounterBox[ "Page"]}], "PageNumber"]}}, CellFrameLabelMargins->6, StyleMenuListing->None] }, Open ]], Cell[CellGroupData[{ Cell["Styles for Headings", "Section"], Cell[CellGroupData[{ Cell[StyleData["Title"], CellMargins->{{12, Inherited}, {20, 40}}, CellGroupingRules->{"TitleGrouping", 0}, PageBreakBelow->False, CounterIncrements->"Title", CounterAssignments->{{"Section", 0}, {"Equation", 0}, {"Figure", 0}, = { "Subtitle", 0}, {"Subsubtitle", 0}}, FontFamily->"Garamond", FontSize->36, FontWeight->"Bold"], Cell[StyleData["Title", "Presentation"], CellMargins->{{24, 10}, {20, 40}}, LineSpacing->{1, 0}, FontSize->44], Cell[StyleData["Title", "Condensed"], CellMargins->{{8, 10}, {4, 8}}, FontSize->20], Cell[StyleData["Title", "Printout"], CellMargins->{{2, 10}, {15, 30}}, FontSize->24] }, Open ]], Cell[CellGroupData[{ Cell[StyleData["Subtitle"], CellMargins->{{12, Inherited}, {10, 15}}, CellGroupingRules->{"TitleGrouping", 10}, PageBreakBelow->False, CounterIncrements->"Subtitle", CounterAssignments->{{"Section", 0}, {"Equation", 0}, {"Figure", 0}, = { "Subsubtitle", 0}}, FontFamily->"Helvetica", FontSize->24], Cell[StyleData["Subtitle", "Presentation"], CellMargins->{{24, 10}, {15, 20}}, LineSpacing->{1, 0}, FontSize->36], Cell[StyleData["Subtitle", "Condensed"], CellMargins->{{8, 10}, {4, 4}}, FontSize->14], Cell[StyleData["Subtitle", "Printout"], CellMargins->{{2, 10}, {10, 15}}, FontSize->18] }, Closed]], Cell[CellGroupData[{ Cell[StyleData["Subsubtitle"], CellMargins->{{12, Inherited}, {10, 20}}, CellGroupingRules->{"TitleGrouping", 20}, PageBreakBelow->False, CounterIncrements->"Subsubtitle", CounterAssignments->{{"Section", 0}, {"Equation", 0}, {"Figure", = 0}}, FontFamily->"Helvetica", FontSize->14, FontSlant->"Italic"], Cell[StyleData["Subsubtitle", "Presentation"], CellMargins->{{24, 10}, {10, 20}}, LineSpacing->{1, 0}, FontSize->24], Cell[StyleData["Subsubtitle", "Condensed"], CellMargins->{{8, 10}, {8, 12}}, FontSize->12], Cell[StyleData["Subsubtitle", "Printout"], CellMargins->{{2, 10}, {8, 10}}, FontSize->14] }, Closed]], Cell[CellGroupData[{ Cell[StyleData["Section"], CellDingbat->"\[FilledSquare]", CellMargins->{{25, Inherited}, {8, 24}}, CellGroupingRules->{"SectionGrouping", 30}, PageBreakBelow->False, CounterIncrements->"Section", CounterAssignments->{{"Subsection", 0}, {"Subsubsection", 0}}, FontFamily->"Helvetica", FontSize->16, FontWeight->"Bold"], Cell[StyleData["Section", "Presentation"], CellMargins->{{40, 10}, {11, 32}}, LineSpacing->{1, 0}, FontSize->24], Cell[StyleData["Section", "Condensed"], CellMargins->{{18, Inherited}, {6, 12}}, FontSize->12], Cell[StyleData["Section", "Printout"], CellMargins->{{13, 0}, {7, 22}}, FontSize->14] }, Open ]], Cell[CellGroupData[{ Cell[StyleData["Subsection"], CellDingbat->"\[FilledSmallSquare]", CellMargins->{{22, Inherited}, {8, 20}}, CellGroupingRules->{"SectionGrouping", 40}, PageBreakBelow->False, CounterIncrements->"Subsection", CounterAssignments->{{"Subsubsection", 0}}, FontSize->14, FontWeight->"Bold"], Cell[StyleData["Subsection", "Presentation"], CellMargins->{{36, 10}, {11, 32}}, LineSpacing->{1, 0}, FontSize->22], Cell[StyleData["Subsection", "Condensed"], CellMargins->{{16, Inherited}, {6, 12}}, FontSize->12], Cell[StyleData["Subsection", "Printout"], CellMargins->{{9, 0}, {7, 22}}, FontSize->12] }, Closed]], Cell[CellGroupData[{ Cell[StyleData["Subsubsection"], CellDingbat->"\[FilledSmallSquare]", CellMargins->{{22, Inherited}, {8, 18}}, CellGroupingRules->{"SectionGrouping", 50}, PageBreakBelow->False, CounterIncrements->"Subsubsection", FontWeight->"Bold"], Cell[StyleData["Subsubsection", "Presentation"], CellMargins->{{34, 10}, {11, 26}}, LineSpacing->{1, 0}, FontSize->18], Cell[StyleData["Subsubsection", "Condensed"], CellMargins->{{17, Inherited}, {6, 12}}, FontSize->10], Cell[StyleData["Subsubsection", "Printout"], CellMargins->{{9, 0}, {7, 14}}, FontSize->11] }, Closed]] }, Open ]], Cell[CellGroupData[{ Cell["Styles for Body Text", "Section"], Cell[CellGroupData[{ Cell[StyleData["Text"], CellMargins->{{12, 10}, {7, 7}}, LineSpacing->{1, 3}, CounterIncrements->"Text"], Cell[StyleData["Text", "Presentation"], CellMargins->{{24, 10}, {10, 10}}, LineSpacing->{1, 5}], Cell[StyleData["Text", "Condensed"], CellMargins->{{8, 10}, {6, 6}}, LineSpacing->{1, 1}], Cell[StyleData["Text", "Printout"], CellMargins->{{2, 2}, {6, 6}}] }, Closed]], Cell[CellGroupData[{ Cell[StyleData["SmallText"], CellMargins->{{12, 10}, {6, 6}}, LineSpacing->{1, 3}, CounterIncrements->"SmallText", FontFamily->"Helvetica", FontSize->9], Cell[StyleData["SmallText", "Presentation"], CellMargins->{{24, 10}, {8, 8}}, LineSpacing->{1, 5}, FontSize->12], Cell[StyleData["SmallText", "Condensed"], CellMargins->{{8, 10}, {5, 5}}, LineSpacing->{1, 2}, FontSize->9], Cell[StyleData["SmallText", "Printout"], CellMargins->{{2, 2}, {5, 5}}, FontSize->7] }, Closed]] }, Open ]], Cell[CellGroupData[{ Cell["Styles for Input/Output", "Section"], Cell["\<\ The cells in this section define styles used for input and output to the = \ kernel. Be careful when modifying, renaming, or removing these styles, = \ because the front end associates special meanings with these style = names.\ \>", "Text"], Cell[CellGroupData[{ Cell[StyleData["Input"], CellMargins->{{45, 10}, {5, 7}}, Evaluatable->True, CellGroupingRules->"InputGrouping", CellHorizontalScrolling->True, PageBreakWithin->False, GroupPageBreakWithin->False, CellLabelMargins->{{11, Inherited}, {Inherited, Inherited}}, DefaultFormatType->DefaultInputFormatType, AutoItalicWords->{}, FormatType->InputForm, ShowStringCharacters->True, NumberMarks->True, CounterIncrements->"Input", FontWeight->"Bold"], Cell[StyleData["Input", "Presentation"], CellMargins->{{72, Inherited}, {8, 10}}, LineSpacing->{1, 0}], Cell[StyleData["Input", "Condensed"], CellMargins->{{40, 10}, {2, 3}}], Cell[StyleData["Input", "Printout"], CellMargins->{{39, 0}, {4, 6}}, FontSize->9] }, Closed]], Cell[StyleData["InputOnly"], Evaluatable->True, CellGroupingRules->"InputGrouping", CellHorizontalScrolling->True, DefaultFormatType->DefaultInputFormatType, AutoItalicWords->{}, FormatType->InputForm, ShowStringCharacters->True, NumberMarks->True, CounterIncrements->"Input", StyleMenuListing->None, FontWeight->"Bold"], Cell[CellGroupData[{ Cell[StyleData["Output"], CellMargins->{{47, 10}, {7, 5}}, CellEditDuplicate->True, CellGroupingRules->"OutputGrouping", CellHorizontalScrolling->True, PageBreakWithin->False, GroupPageBreakWithin->False, GeneratedCell->True, CellAutoOverwrite->True, CellLabelMargins->{{11, Inherited}, {Inherited, Inherited}}, DefaultFormatType->DefaultOutputFormatType, AutoItalicWords->{}, FormatType->InputForm, CounterIncrements->"Output"], Cell[StyleData["Output", "Presentation"], CellMargins->{{72, Inherited}, {10, 8}}, LineSpacing->{1, 0}], Cell[StyleData["Output", "Condensed"], CellMargins->{{41, Inherited}, {3, 2}}], Cell[StyleData["Output", "Printout"], CellMargins->{{39, 0}, {6, 4}}, FontSize->9] }, Closed]], Cell[CellGroupData[{ Cell[StyleData["Message"], CellMargins->{{45, Inherited}, {Inherited, Inherited}}, CellGroupingRules->"OutputGrouping", PageBreakWithin->False, GroupPageBreakWithin->False, GeneratedCell->True, CellAutoOverwrite->True, ShowCellLabel->False, CellLabelMargins->{{11, Inherited}, {Inherited, Inherited}}, DefaultFormatType->DefaultOutputFormatType, AutoItalicWords->{}, FormatType->InputForm, CounterIncrements->"Message", StyleMenuListing->None, FontColor->RGBColor[0, 0, 1]], Cell[StyleData["Message", "Presentation"], CellMargins->{{72, Inherited}, {Inherited, Inherited}}, LineSpacing->{1, 0}], Cell[StyleData["Message", "Condensed"], CellMargins->{{41, Inherited}, {Inherited, Inherited}}], Cell[StyleData["Message", "Printout"], CellMargins->{{39, Inherited}, {Inherited, Inherited}}, FontSize->8, FontColor->GrayLevel[0]] }, Closed]], Cell[CellGroupData[{ Cell[StyleData["Print"], CellMargins->{{45, Inherited}, {Inherited, Inherited}}, CellGroupingRules->"OutputGrouping", CellHorizontalScrolling->True, PageBreakWithin->False, GroupPageBreakWithin->False, GeneratedCell->True, CellAutoOverwrite->True, ShowCellLabel->False, CellLabelMargins->{{11, Inherited}, {Inherited, Inherited}}, DefaultFormatType->DefaultOutputFormatType, AutoItalicWords->{}, FormatType->InputForm, CounterIncrements->"Print", StyleMenuListing->None], Cell[StyleData["Print", "Presentation"], CellMargins->{{72, Inherited}, {Inherited, Inherited}}, LineSpacing->{1, 0}], Cell[StyleData["Print", "Condensed"], CellMargins->{{41, Inherited}, {Inherited, Inherited}}], Cell[StyleData["Print", "Printout"], CellMargins->{{39, Inherited}, {Inherited, Inherited}}, FontSize->8] }, Closed]], Cell[CellGroupData[{ Cell[StyleData["Graphics"], CellMargins->{{4, Inherited}, {Inherited, Inherited}}, CellGroupingRules->"GraphicsGrouping", CellHorizontalScrolling->True, PageBreakWithin->False, GeneratedCell->True, CellAutoOverwrite->True, ShowCellLabel->False, DefaultFormatType->DefaultOutputFormatType, FormatType->InputForm, CounterIncrements->"Graphics", ImageMargins->{{43, Inherited}, {Inherited, 0}}, StyleMenuListing->None], Cell[StyleData["Graphics", "Presentation"], ImageMargins->{{62, Inherited}, {Inherited, 0}}], Cell[StyleData["Graphics", "Condensed"], ImageSize->{175, 175}, ImageMargins->{{38, Inherited}, {Inherited, 0}}], Cell[StyleData["Graphics", "Printout"], ImageSize->{250, 250}, ImageMargins->{{30, Inherited}, {Inherited, 0}}, FontSize->9] }, Closed]], Cell[CellGroupData[{ Cell[StyleData["CellLabel"], StyleMenuListing->None, FontFamily->"Helvetica", FontSize->9, FontColor->RGBColor[0, 0, 1]], Cell[StyleData["CellLabel", "Presentation"], FontSize->12], Cell[StyleData["CellLabel", "Condensed"], FontSize->9], Cell[StyleData["CellLabel", "Printout"], FontFamily->"Courier", FontSize->8, FontSlant->"Italic", FontColor->GrayLevel[0]] }, Closed]] }, Open ]], Cell[CellGroupData[{ Cell["Formulas and Programming", "Section"], Cell[CellGroupData[{ Cell[StyleData["InlineFormula"], CellMargins->{{10, 4}, {0, 8}}, CellHorizontalScrolling->True, ScriptLevel->1, SingleLetterItalics->True], Cell[StyleData["InlineFormula", "Presentation"], CellMargins->{{24, 10}, {10, 10}}, LineSpacing->{1, 5}], Cell[StyleData["InlineFormula", "Condensed"], CellMargins->{{8, 10}, {6, 6}}, LineSpacing->{1, 1}], Cell[StyleData["InlineFormula", "Printout"], CellMargins->{{2, 0}, {6, 6}}] }, Closed]], Cell[CellGroupData[{ Cell[StyleData["DisplayFormula"], CellMargins->{{42, Inherited}, {Inherited, Inherited}}, CellHorizontalScrolling->True, ScriptLevel->0, SingleLetterItalics->True, StyleMenuListing->None, UnderoverscriptBoxOptions->{LimitsPositioning->True}], Cell[StyleData["DisplayFormula", "Presentation"], LineSpacing->{1, 5}], Cell[StyleData["DisplayFormula", "Condensed"], LineSpacing->{1, 1}], Cell[StyleData["DisplayFormula", "Printout"]] }, Closed]] }, Open ]], Cell[CellGroupData[{ Cell["Styles for Headers and Footers", "Section"], Cell[StyleData["Header"], CellMargins->{{0, 0}, {4, 1}}, StyleMenuListing->None, FontSize->10, FontSlant->"Italic"], Cell[StyleData["Footer"], CellMargins->{{0, 0}, {0, 4}}, StyleMenuListing->None, FontSize->9, FontSlant->"Italic"], Cell[StyleData["PageNumber"], CellMargins->{{0, 0}, {4, 1}}, StyleMenuListing->None, FontFamily->"Times", FontSize->10] }, Open ]], Cell[CellGroupData[{ Cell["Palette Styles", "Section"], Cell["\<\ The cells below define styles that define standard ButtonFunctions, for = use \ in palette buttons.\ \>", "Text"], Cell[StyleData["Paste"], StyleMenuListing->None, ButtonStyleMenuListing->Automatic, ButtonBoxOptions->{ButtonFunction:>(FrontEndExecute[ { FrontEnd`NotebookApply[ FrontEnd`InputNotebook[ ], #, After]}]&)}], Cell[StyleData["Evaluate"], StyleMenuListing->None, ButtonStyleMenuListing->Automatic, ButtonBoxOptions->{ButtonFunction:>(FrontEndExecute[ { FrontEnd`NotebookApply[ FrontEnd`InputNotebook[ ], #, All], SelectionEvaluate[ FrontEnd`InputNotebook[ ], All]}]&)}], Cell[StyleData["EvaluateCell"], StyleMenuListing->None, ButtonStyleMenuListing->Automatic, ButtonBoxOptions->{ButtonFunction:>(FrontEndExecute[ { FrontEnd`NotebookApply[ FrontEnd`InputNotebook[ ], #, All], FrontEnd`SelectionMove[ FrontEnd`InputNotebook[ ], All, Cell, 1], FrontEnd`SelectionEvaluateCreateCell[ FrontEnd`InputNotebook[ ], All]}]&)}], Cell[StyleData["CopyEvaluate"], StyleMenuListing->None, ButtonStyleMenuListing->Automatic, ButtonBoxOptions->{ButtonFunction:>(FrontEndExecute[ { FrontEnd`SelectionCreateCell[ FrontEnd`InputNotebook[ ], All], FrontEnd`NotebookApply[ FrontEnd`InputNotebook[ ], #, All], FrontEnd`SelectionEvaluate[ FrontEnd`InputNotebook[ ], All]}]&)}], Cell[StyleData["CopyEvaluateCell"], StyleMenuListing->None, ButtonStyleMenuListing->Automatic, ButtonBoxOptions->{ButtonFunction:>(FrontEndExecute[ { FrontEnd`SelectionCreateCell[ FrontEnd`InputNotebook[ ], All], FrontEnd`NotebookApply[ FrontEnd`InputNotebook[ ], #, All], FrontEnd`SelectionEvaluateCreateCell[ FrontEnd`InputNotebook[ ], All]}]&)}] }, Open ]], Cell[CellGroupData[{ Cell["Hyperlink Styles", "Section"], Cell["\<\ The cells below define styles useful for making hypertext ButtonBoxes. = The \ \"Hyperlink\" style is for links within the same Notebook, or between \ Notebooks.\ \>", "Text"], Cell[CellGroupData[{ Cell[StyleData["Hyperlink"], StyleMenuListing->None, ButtonStyleMenuListing->Automatic, FontColor->RGBColor[0, 0, 1], FontVariations->{"Underline"->True}, ButtonBoxOptions->{ButtonFunction:>(FrontEndExecute[ { FrontEnd`NotebookLocate[ #2]}]&), Active->True, ButtonNote->ButtonData}], Cell[StyleData["Hyperlink", "Presentation"]], Cell[StyleData["Hyperlink", "Condensed"]], Cell[StyleData["Hyperlink", "Printout"], FontColor->GrayLevel[0], FontVariations->{"Underline"->False}] }, Closed]], Cell["\<\ The following styles are for linking automatically to the on-line help \ system.\ \>", "Text"], Cell[CellGroupData[{ Cell[StyleData["MainBookLink"], StyleMenuListing->None, ButtonStyleMenuListing->Automatic, FontColor->RGBColor[0, 0, 1], FontVariations->{"Underline"->True}, ButtonBoxOptions->{ButtonFunction:>(FrontEndExecute[ { FrontEnd`HelpBrowserLookup[ "MainBook", #]}]&), Active->True, ButtonFrame->"None"}], Cell[StyleData["MainBookLink", "Presentation"]], Cell[StyleData["MainBookLink", "Condensed"]], Cell[StyleData["MainBookLink", "Printout"], FontColor->GrayLevel[0], FontVariations->{"Underline"->False}] }, Closed]], Cell[CellGroupData[{ Cell[StyleData["AddOnsLink"], StyleMenuListing->None, ButtonStyleMenuListing->Automatic, FontFamily->"Courier", FontColor->RGBColor[0, 0, 1], FontVariations->{"Underline"->True}, ButtonBoxOptions->{ButtonFunction:>(FrontEndExecute[ { FrontEnd`HelpBrowserLookup[ "AddOns", #]}]&), Active->True, ButtonFrame->"None"}], Cell[StyleData["AddOnsLink", "Presentation"]], Cell[StyleData["AddOnsLink", "Condensed"]], Cell[StyleData["AddOnLink", "Printout"], FontColor->GrayLevel[0], FontVariations->{"Underline"->False}] }, Closed]], Cell[CellGroupData[{ Cell[StyleData["RefGuideLink"], StyleMenuListing->None, ButtonStyleMenuListing->Automatic, FontFamily->"Courier", FontColor->RGBColor[0, 0, 1], FontVariations->{"Underline"->True}, ButtonBoxOptions->{ButtonFunction:>(FrontEndExecute[ { FrontEnd`HelpBrowserLookup[ "RefGuideLink", #]}]&), Active->True, ButtonFrame->"None"}], Cell[StyleData["RefGuideLink", "Presentation"]], Cell[StyleData["RefGuideLink", "Condensed"]], Cell[StyleData["RefGuideLink", "Printout"], FontColor->GrayLevel[0], FontVariations->{"Underline"->False}] }, Closed]], Cell[CellGroupData[{ Cell[StyleData["GettingStartedLink"], StyleMenuListing->None, ButtonStyleMenuListing->Automatic, FontColor->RGBColor[0, 0, 1], FontVariations->{"Underline"->True}, ButtonBoxOptions->{ButtonFunction:>(FrontEndExecute[ { FrontEnd`HelpBrowserLookup[ "GettingStarted", #]}]&), Active->True, ButtonFrame->"None"}], Cell[StyleData["GettingStartedLink", "Presentation"]], Cell[StyleData["GettingStartedLink", "Condensed"]], Cell[StyleData["GettingStartedLink", "Printout"], FontColor->GrayLevel[0], FontVariations->{"Underline"->False}] }, Closed]], Cell[CellGroupData[{ Cell[StyleData["OtherInformationLink"], StyleMenuListing->None, ButtonStyleMenuListing->Automatic, FontColor->RGBColor[0, 0, 1], FontVariations->{"Underline"->True}, ButtonBoxOptions->{ButtonFunction:>(FrontEndExecute[ { FrontEnd`HelpBrowserLookup[ "OtherInformation", #]}]&), Active->True, ButtonFrame->"None"}], Cell[StyleData["OtherInformationLink", "Presentation"]], Cell[StyleData["OtherInformationLink", "Condensed"]], Cell[StyleData["OtherInformationLink", "Printout"], FontColor->GrayLevel[0], FontVariations->{"Underline"->False}] }, Closed]] }, Open ]], Cell[CellGroupData[{ Cell["Placeholder Styles", "Section"], Cell["\<\ The cells below define styles useful for making placeholder objects in \ palette templates.\ \>", "Text"], Cell[CellGroupData[{ Cell[StyleData["Placeholder"], Editable->False, Selectable->False, StyleBoxAutoDelete->True, Placeholder->True, StyleMenuListing->None], Cell[StyleData["Placeholder", "Presentation"]], Cell[StyleData["Placeholder", "Condensed"]], Cell[StyleData["Placeholder", "Printout"]] }, Open ]], Cell[CellGroupData[{ Cell[StyleData["SelectionPlaceholder"], Editable->False, Selectable->False, StyleBoxAutoDelete->True, Placeholder->Primary, StyleMenuListing->None, DrawHighlighted->True], Cell[StyleData["SelectionPlaceholder", "Presentation"]], Cell[StyleData["SelectionPlaceholder", "Condensed"]], Cell[StyleData["SelectionPlaceholder", "Printout"]] }, Closed]] }, Open ]], Cell[CellGroupData[{ Cell["FormatType Styles", "Section"], Cell["\<\ The cells below define styles that are mixed in with the styles of most = \ cells. If a cell's FormatType matches the name of one of the styles = defined \ below, then that style is applied between the cell's style and its own \ options.\ \>", "Text"], Cell[StyleData["CellExpression"], PageWidth->Infinity, CellMargins->{{6, Inherited}, {Inherited, Inherited}}, ShowCellLabel->False, ShowSpecialCharacters->False, AllowInlineCells->False, AutoItalicWords->{}, StyleMenuListing->None, FontFamily->"Courier", Background->GrayLevel[1]], Cell[StyleData["InputForm"], AllowInlineCells->False, StyleMenuListing->None, FontFamily->"Courier"], Cell[StyleData["OutputForm"], PageWidth->Infinity, TextAlignment->Left, LineSpacing->{1, -5}, StyleMenuListing->None, FontFamily->"Courier"], Cell[StyleData["StandardForm"], LineSpacing->{1.25, 0}, StyleMenuListing->None, FontFamily->"Courier"], Cell[StyleData["TraditionalForm"], LineSpacing->{1.25, 0}, SingleLetterItalics->True, TraditionalFunctionNotation->True, DelimiterMatching->None, StyleMenuListing->None], Cell["\<\ The style defined below is mixed in to any cell that is in an inline = cell \ within another.\ \>", "Text"], Cell[StyleData["InlineCell"], TextAlignment->Left, ScriptLevel->1, StyleMenuListing->None], Cell[StyleData["InlineCellEditing"], StyleMenuListing->None, Background->RGBColor[1, 0.749996, 0.8]] }, Open ]] }, Open ]] }] ] (*********************************************************************** 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[1709, 49, 406, 11, 224, "Text"], Cell[CellGroupData[{ Cell[2140, 64, 40, 0, 102, "Title"], Cell[CellGroupData[{ Cell[2205, 68, 47, 0, 53, "Section"], Cell[2255, 70, 172, 4, 60, "SmallText"], Cell[2430, 76, 242, 8, 133, "Text", Evaluatable->True], Cell[2675, 86, 76, 3, 44, "SmallText"] }, Open ]], Cell[CellGroupData[{ Cell[2788, 94, 31, 0, 53, "Section"], Cell[2822, 96, 136, 3, 33, "Text"], Cell[2961, 101, 73, 1, 30, "Input"], Cell[3037, 104, 73, 1, 30, "Input"], Cell[3113, 107, 113, 3, 33, "Text"], Cell[3229, 112, 1407, 44, 110, "Input"], Cell[4639, 158, 49, 1, 30, "Input"], Cell[4691, 161, 49, 1, 30, "Input"], Cell[4743, 164, 50, 1, 30, "Input"], Cell[4796, 167, 49, 1, 30, "Input"], Cell[4848, 170, 49, 0, 33, "Text"], Cell[4900, 172, 45, 1, 30, "Input"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[4994, 179, 41, 0, 102, "Title"], Cell[CellGroupData[{ Cell[5060, 183, 49, 0, 53, "Section"], Cell[5112, 185, 739, 16, 290, "Input", InitializationCell->True] }, Open ]], Cell[CellGroupData[{ Cell[5888, 206, 23, 0, 53, "Section"], Cell[5914, 208, 110, 2, 30, "Input"], Cell[6027, 212, 53, 1, 30, "Input"], Cell[6083, 215, 55, 1, 30, "Input"], Cell[6141, 218, 53, 1, 30, "Input"], Cell[6197, 221, 58, 1, 30, "Input"], Cell[6258, 224, 53, 1, 30, "Input"] }, Open ]] }, Open ]] } ] *) (*********************************************************************** End of Mathematica Notebook file. ***********************************************************************) ------------------------------ Jean-Marie THOMAS Conseil et Audit en Ing=E9nierie de Calcul jmthomas at cybercable.tm.fr www.cybercable.tm.fr/~jmthomas -----Message d'origine----- De: Gadi Oron [SMTP:oron at manet.pmmh.espci.fr] Date: lundi 27 octobre 1997 08:47 =C0: mathgroup at smc.vnet.net Objet: [mg9287] Static variables Hi there, Does anybody knows how to (easily) define static variables in Mathematica functions (i.e. variables which values are kept between two calls to the function but are not global). Thank you. \/\\/\/\/>> Gadi ORON <<\/\/\/\/ o o \_____/ EMAIL : oron at pmmh.espci.fr /=O=O=\ _______ Soyez braves - Be brave / ^ \ /\\\\\\\\ \ \___/ / /\ ___ \ \_ _/ /\ /\\\\ \ \ \__/\ /\ @_/ / \____\____\______/ Homepage : http://www.pmmh.espci.fr/~oron/personal.html