Io lists are comparable to Python's. There is no list literal (like Python's []); rather, the list() method is used.
Python: [1, 2, 3] Io: list(1, 2, 3)
Getting/setting the item at position N:
a := list("Niffler", "Flurry", "Bookie")
a at(1)
#=> "Flurry"
a atPut(2, "Bighead")
#=> list("Niffler", "Flurry", "Bighead")
a at(3)
#=> nil # item does not exist
a atPut(3, "Fred")
# Exception: index out of bounds
Appending an item:
...
Inserting an item at position N:
...
Io's map and select (known as filter in some other languages) methods are very powerful. They allow arbitrary expressions as the map/select predicates.
Io> numbers := list(1, 2, 3, 4, 5, 6) Io> numbers select(isOdd) #=> list(1, 3, 5) Io> numbers select(x, x isOdd) #=> list(1, 3, 5) Io> numbers select(i, x, x isOdd) #=> list(1, 3, 5) Io> numbers map(x, x*2) #=> list(2, 4, 6, 8, 10, 12) Io> numbers map(i, x, x+i) #=> list(1, 3, 5, 7, 9, 11) Io> numbers map(*3) #=> list(3, 6, 9, 12, 15, 18)
Also see foreach.