Arrays in AAQZ6
Table of Contents
1. Array Examples
{bind [arr = {array 10 20 30}] {seq {aset arr 2 100} {aref arr 2}}}
env
arr -> 3
Swap
def swap(arr, i, j): tmp = arr[i] arr[i] = arr[j] # -> structoral mutation arr[j] = tmp # -> structoral mutation
{bind [swap = {(arr i j) => }] {bind [tmp = {aref arr i}] {seq {aset arr i {aref arr j}} {aset arr j tmp}}}}] {bind [my_arr = {array 10 20 30}] {seq {swap my_arr 0 2} {aref my_array 2}}}}
you can keep track of store length so you know where to add