Getting a memory reference to different parts of an array

Suppose I have an array x = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]. Does there exist syntactial sugar, so I can write something like

a = x[1:3] 
b = x[4:7] 
c = x[8:10]

so that b[1] actually refers to x[4] and that b[1] = value actually mutates x? Is this something I can do with Ref?

Answered my own question. Have to use view`

a = view(x, 1:3)
b = view(x, 4:7)
c = view(x, 8:10)
2 Likes

Also have a look at the @view and @views macros.

3 Likes