Files
pplus-library/mojo/probes/list-slice-copy.mojo
T
alexm 568474d52f
Test (in pplus-core) / in-core (push) Failing after 28m44s
Initial commit
2026-11-12 22:23:48 -05:00

32 lines
902 B
Mojo

# probe: List[T](l[lo:hi]) is a new List holding copies of the items, not a view of l: changes to either afterwards stay apart; empty, whole and open-ended slices
def main():
var l: List[Int] = [1, 2, 3, 4, 5]
var m = List[Int](l[1:3])
print(m, len(m))
l[1] = 20
m.append(9)
print(l, m)
var e = List[Int](l[2:2])
print(e, len(e))
e.append(7)
print(e)
var w = List[Int](l[0:len(l)])
print(w)
var s: List[String] = ["a", "b", "c"]
var t = List[String](s[1:3])
s[1] = "z"
print(t, s)
var g: List[List[Int]] = [[1], [2, 3]]
var h = List[List[Int]](g[0:2])
g[1].append(4)
h[0].append(5)
print(g, h)
var fl: List[Float64] = [1.5, 2.5]
print(List[Float64](fl[0:1]))
var x = List[Int](l[:2])
var y = List[Int](l[3:])
print(x, y)
var _value1: List[Int] = List[Int](l[1:4])
l = _value1^
print(l)