This commit is contained in:
commit
568474d52f
1591 files changed
+528213
No files matched your search
@@ -0,0 +1,31 @@
|
||||
# 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)
|
||||
Reference in new issue
Block a user