15 lines
566 B
Text
15 lines
566 B
Text
^|EMal has dynamic lists.
|
|
|Lists have different API to change the value in-place or not.
|
|
|SQL-ish methods like: insert, append, delete, order, alter the current list.
|
|
|Different methods operate on indexes or on values.
|
|
|^
|
|
List a ← int[] # a:[]
|
|
a.append(8) # a:[8]
|
|
a.insert(1, 13) # a:[8,13]
|
|
a.delete(0) # a:[13]
|
|
a.clear() # a:[]
|
|
a.of(21, 33) # a:[21,33]
|
|
a[1] ← 34 # a:[21,34]
|
|
List b ← a.remove(21) # a:[21, 34], b:[34]
|
|
writeLine("a has ", a.length, " items, their values are ", a[0], ", ", a[1])
|
|
writeLine("b has ", b.length, " item, its value is ", b[0])
|