Skip to content

Commit 5237114

Browse files
committed
clarify range indexing, fixes #638
1 parent 17d4097 commit 5237114

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/reference-manual/expressions.qmd

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -782,8 +782,10 @@ In addition to single integer indexes, as described in
782782
[the language indexing section](#language-indexing.section), Stan supports multiple indexing.
783783
Multiple indexes can be integer arrays of indexes, lower
784784
bounds, upper bounds, lower and upper bounds, or simply shorthand for
785-
all of the indexes. A complete table of index types is given in the
786-
following table.
785+
all of the indexes. If the upper bound is smaller than the lower bound,
786+
the range is empty (unlike, e.g. in R). Upper bound and lower bound can be
787+
expressions that evaluate to integer. A complete table of index types is
788+
given in the following table.
787789

788790
##### Indexing Options Table {- #index-types-table}
789791

@@ -797,6 +799,8 @@ following table.
797799
| lower bound | `a[3:]` | `a[3]`, ..., `a[N]` |
798800
| upper bound | `a[:5]` | `a[1]`, ..., `a[5]` |
799801
| range | `a[2:7]` | `a[2]`, ..., `a[7]` |
802+
| range | `a[7:2]` | [] |
803+
| range | `a[5-3:5+2]` | `a[2]`, ..., `a[7]` |
800804
| all | `a[:]` | `a[1]`, ..., `a[N]` |
801805
| all | `a[]` | `a[1]`, ..., `a[N]` |
802806

0 commit comments

Comments
 (0)