JSAbrahams / mamba

🐍 The Mamba programming language, because we care about safety
MIT License
85 stars 3 forks source link

Index access of arrays #172

Closed JSAbrahams closed 2 years ago

JSAbrahams commented 4 years ago

Current Issue

We cannot access array indices

High-level description of the feature

Allow accessing of array indices.

def list := [1,2,3,4,5]

# should print 3
print(list[2])

Also, allow indices which allow us to take slices of arrays:

def x := [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

# all print [1, 2, 3, 4, 5]
print(x[0::5])

# prints [1, 3, 5]
print x[0::5::2]

Description of potential implementation