Skip to content

Commit

Permalink
docs: Small edits to noteworthy differences (#55852)
Browse files Browse the repository at this point in the history
- The first line edit changes it so that the Julia example goes first,
not the Python example, keeping with the general flow of the lines
above.
- The second adds a "the" that is missing.
  • Loading branch information
RichardLitt authored Sep 24, 2024
1 parent c3af4fc commit 2943833
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions doc/src/manual/noteworthy-differences.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,8 @@ For users coming to Julia from R, these are some noteworthy differences:
* Unlike Python, Julia allows [AbstractArrays with arbitrary indexes](https://julialang.org/blog/2017/04/offset-arrays/).
Python's special interpretation of negative indexing, `a[-1]` and `a[-2]`, should be written
`a[end]` and `a[end-1]` in Julia.
* Julia requires `end` for indexing until the last element. `x[1:]` in Python is equivalent to `x[2:end]` in Julia.
* In Julia, `:` before any object creates a [`Symbol`](@ref) or *quotes* an expression; so, `x[:5]` is same as `x[5]`. If you want to get the first `n` elements of an array, then use range indexing.
* Julia requires `end` for indexing until the last element. `x[2:end]` in Julia is equivalent to `x[1:]` in Python.
* In Julia, `:` before any object creates a [`Symbol`](@ref) or *quotes* an expression; so, `x[:5]` is the same as `x[5]`. If you want to get the first `n` elements of an array, then use range indexing.
* Julia's range indexing has the format of `x[start:step:stop]`, whereas Python's format is `x[start:(stop+1):step]`. Hence, `x[0:10:2]` in Python is equivalent to `x[1:2:10]` in Julia. Similarly, `x[::-1]` in Python, which refers to the reversed array, is equivalent to `x[end:-1:1]` in Julia.
* In Julia, ranges can be constructed independently as `start:step:stop`, the same syntax it uses
in array-indexing. The `range` function is also supported.
Expand Down

0 comments on commit 2943833

Please sign in to comment.