Skip to content

Commit

Permalink
Allow end for non-integer indexing.
Browse files Browse the repository at this point in the history
  • Loading branch information
HansOlsson committed Dec 15, 2020
1 parent 46bd6d7 commit ab856a8
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions chapters/arrays.tex
Expand Up @@ -1021,14 +1021,18 @@ \subsection{Indexing with Boolean or Enumeration Values}\label{indexing-with-boo

\subsection{Indexing with end}\label{indexing-with-end}

The expression \lstinline!end! may only appear inside array subscripts, and if used in the $i$:th subscript of an array expression \lstinline!A! it is equivalent
to \lstinline!size(A, $i$)! provided indices to \lstinline!A! are a subtype of \lstinline!Integer!. If used inside nested array subscripts it refers
to the most closely nested array.

The expression \lstinline!end! may only appear inside array subscripts, and if used in the $i$:th subscript of an array expression \lstinline!A! it is equivalent to the upper bound of the $i$:th dimension of \lstinline!A!.
If used inside nested array subscripts it refers to the most closely nested array.
\begin{nonnormative}
If indices to \lstinline!A! are a subtype of \lstinline!Integer! it is equivalent to \lstinline!size(A,i)!.
\end{nonnormative}
\begin{example}
\begin{lstlisting}[language=modelica, escapechar=!]
A[end - 1, end] !is! A[size(A,1) - 1, size(A,2)]
A[v[end], end] !is! A[v[size(v,1)], size(A,2)] // !\emph{First}! end !\emph{is referring to end of v.}!

Real B[Boolean];
B[end] !is! B[true]
\end{lstlisting}
\end{example}

Expand Down

0 comments on commit ab856a8

Please sign in to comment.