2015-06-04 06:52:16 -04:00
|
|
|
# test standard Python subscr using viper types
|
|
|
|
|
2021-03-15 09:57:36 -04:00
|
|
|
|
2015-06-04 06:52:16 -04:00
|
|
|
@micropython.viper
|
2021-03-15 09:57:36 -04:00
|
|
|
def get(dest, i: int):
|
2015-06-04 06:52:16 -04:00
|
|
|
i += 1
|
|
|
|
return dest[i]
|
|
|
|
|
2021-03-15 09:57:36 -04:00
|
|
|
|
2015-06-04 06:52:16 -04:00
|
|
|
@micropython.viper
|
2021-03-15 09:57:36 -04:00
|
|
|
def set(dest, i: int, val: int):
|
2015-06-04 06:52:16 -04:00
|
|
|
i += 1
|
|
|
|
dest[i] = val + 1
|
|
|
|
|
2021-03-15 09:57:36 -04:00
|
|
|
|
2015-06-04 06:52:16 -04:00
|
|
|
ar = [i for i in range(3)]
|
|
|
|
|
|
|
|
for i in range(len(ar)):
|
|
|
|
set(ar, i - 1, i)
|
|
|
|
print(ar)
|
|
|
|
|
|
|
|
for i in range(len(ar)):
|
|
|
|
print(get(ar, i - 1))
|