Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow end for non-integer indexing. #2766

Merged
merged 1 commit into from Dec 16, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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