6 Jun
2019
6 Jun
'19
11:56 p.m.
Stephen J. Turnbull wrote:
L[m:m+k] specifies that a list operation will take place on the k elements starting with m. As a value, it makes a new list of references to those elements.
Even that is specific to lists. There's no requirement that a RHS slice has to create new references to elements. A type can define it so that it returns a mutable view of part of the original object. This is how numpy arrays behave, for example. As syntax, slice notation simply denotes a range of elements, and it does that the same way whether it's on the LHS or RHS. -- Greg