From 7d6875061f96ec34aead73d07d02b6ae69ac6b13 Mon Sep 17 00:00:00 2001 From: Henrik Tidefelt Date: Tue, 10 May 2022 12:03:31 +0200 Subject: [PATCH] Minor cleanup for for-equation listings --- chapters/equations.tex | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/chapters/equations.tex b/chapters/equations.tex index 47872e9e5..c6b027ad2 100644 --- a/chapters/equations.tex +++ b/chapters/equations.tex @@ -115,7 +115,7 @@ \subsubsection{Explicit Iteration Ranges of For-Equations}\label{explicit-iterat for r in 1.0 : 1.5 : 5.5 loop // r takes the values 1.0, 2.5, 4.0, 5.5 for i in {1, 3, 6, 7} loop // i takes the values 1, 3, 6, 7 for i in TwoEnums loop // i takes the values TwoEnums.one, TwoEnums.two - // for TwoEnums = enumeration(one,two) + // for TwoEnums = enumeration(one, two) \end{lstlisting} The loop-variable may hide other variables as in the following example. @@ -124,8 +124,8 @@ \subsubsection{Explicit Iteration Ranges of For-Equations}\label{explicit-iterat constant Integer j = 4; Real x[j] equation - for j in 1:j loop // The loop-variable j takes the values 1,2,3,4 - x[j] = j; // Uses the loop-variable j + for j in 1 : j loop // j takes the values 1, 2, 3, 4 + x[j] = j; // Uses the loop-variable j end for; \end{lstlisting} \end{example} @@ -138,10 +138,11 @@ \subsubsection{Implicit Iteration Ranges of For-Equations}\label{implicit-iterat \begin{example} \begin{lstlisting}[language=modelica] - Real x[n],y[n]; -for i loop // Same as: for i in 1:size(x ,1) loop - x[i] = 2*y[i]; -end for; + Real x[n], y[n]; +equation + for i loop // Same as: for i in 1 : size(x, 1) loop + x[i] = 2 * y[i]; + end for; \end{lstlisting} \end{example}