List[Null, Null, Null, Null, Null, Null, Null, Notebook[List[Cell[CellGroupData[List[Cell["Exercise 2", "Title"], Cell[CellGroupData[List[Cell["Using Algorithm Sections", "Section"], Cell[TextData[List["Write a class, ", StyleBox["FindSmallest", Rule[FontFamily, "Courier"]], ", that finds the value and position of the smallest element in an arbitrary array."]], "Text"], Cell["", "ModelicaInput"], Cell[TextData[List["\nWrite a class that makes an instance of the ", StyleBox["FindSmallest", Rule[FontFamily, "Courier"]], " class and give the array values."]], "Text"], Cell["", "ModelicaInput"], Cell[CellGroupData[List[Cell["Answer", "Subsection"], Cell[CellGroupData[List[Cell["FindSmallest", "Subsubsection"], Cell["Loop through all elements in the array except the first. The smallest value is initially the first value in the array. ", "Text"], Cell["class FindSmallest\n  Real A[:];\n  Real smallest;\n  Integer place;\nalgorithm\n  smallest := A[1];\n  place := 1;\n  for i in 2:size(A, 1) loop\n    if A[i] < smallest then\n      smallest := A[i];     \n      place := i;  \n    end if;   \n  end for;    \nend FindSmallest;", "ModelicaInput"]], Closed]], Cell[CellGroupData[List[Cell["FindSmallestElement", "Subsubsection"], Cell["class FindSmallestElement\n  FindSmallest findsmallest(A={9, 5, 8, 7, 2, 4});\nend FindSmallestElement;", "ModelicaInput"]], Closed]], Cell[CellGroupData[List[Cell["Simulation of FindSmallestElement", "Subsubsection"], Cell["simulate( FindSmallestElement );", "ModelicaInput"], Cell[BoxData["\"<SimulationData: \\!\\(FindSmallestElement\\) : 2004-1-30 14:54:28.5017675 : \\!\\({0.`, 1.`}\\) : 502 data points : 1 events : 10 variables>\\n\\!\\({\\*TagBox[\\\"\[UnderBracket]derdummy\\\", HoldForm], \\*TagBox[\\\"\[UnderBracket]dummy\\\", HoldForm], \\*TagBox[\\(\\(\\(findsmallest . A\\)\\) \[LeftDoubleBracket] \\(\\(1\\)\\) \[RightDoubleBracket]\\), HoldForm], \\*TagBox[\\(\\(\\(findsmallest . A\\)\\) \[LeftDoubleBracket] \\(\\(2\\)\\) \[RightDoubleBracket]\\), HoldForm], \\*TagBox[\\(\\(\\(findsmallest . A\\)\\) \[LeftDoubleBracket] \\(\\(3\\)\\) \[RightDoubleBracket]\\), HoldForm], \\*TagBox[\\(\\(\\(findsmallest . A\\)\\) \[LeftDoubleBracket] \\(\\(4\\)\\) \[RightDoubleBracket]\\), HoldForm], \\*TagBox[\\(\\(\\(findsmallest . A\\)\\) \[LeftDoubleBracket] \\(\\(5\\)\\) \[RightDoubleBracket]\\), HoldForm], \\*TagBox[\\(\\(\\(findsmallest . A\\)\\) \[LeftDoubleBracket] \\(\\(6\\)\\) \[RightDoubleBracket]\\), HoldForm], \\*TagBox[\\(findsmallest . place\\), HoldForm], \\*TagBox[\\(findsmallest . smallest\\), HoldForm]}\\)\""], "Output"], Cell["Here we can see that the smallest value in the array is the element in position 5 with the value 2.", "Text"], Cell[BoxData[RowBox[List["{", RowBox[List[RowBox[List["findsmallest", ".", RowBox[List["smallest", "[", "1", "]"]]]], ",", " ", RowBox[List["findsmallest", ".", RowBox[List["place", "[", "1", "]"]]]]]], "}"]]], "Input"]], Closed]]], Closed]]], Open]]], Open]]], Rule[FrontEndVersion, "5.1 for Microsoft Windows"], Rule[ScreenRectangle, List[List[0, 1280], List[0, 951]]], Rule[WindowSize, List[727, 913]], Rule[WindowMargins, List[List[3, Automatic], List[Automatic, 0]]], Rule[StyleDefinitions, "MathModelica.nb"]], Null, Null, Null, Null, Null]