Stuff
public text v1 · immutableclass FlatListAccessor:
def __init__(self, l, width):
self.list = l
self.width = width
def __getitem__(self, coordinates):
x, y = coordinates
return self.list[x+self.width*y]
used like this:
>>> data = FlatListAccessor([0,0,0,0,1,2,0,2,4], 3)
>>> data[0,0]
0
>>> data[0,1]
0
>>> data[1,1]
1
>>> data[2,2]
4