AGET

Syntax

AGET array number or list

Explanation

AGET outputs the value in a specific location of an array as specified by its inputs. The first element of its input is the array to be accessed, while the second element describes the array element to be obtained. For one-dimensional arrays, the second element may be a number starting from 0; for multi-dimensional arrays, the input element is a list of numbers, where each number stands for one dimension. Bytearrays always output numbers between 0 and 255, while arrays output the value stored in the accessed element. If no value is stored, bytearrays output 0 while arrays output an empty list [].

Examples

? MAKE "A ARRAY [2 2]

? AGET :A [1 0]

Result: []

? ASET :A [1 1] [SQUARE 4]

? AGET :A [1 1]

Result: [SQUARE 4]

? MAKE "B BYTEARRAY [2 2]

? AGET :B [1 0]

Result: 0

? ASET :B [1 1] 10

? AGET :B [1 1]

Result: 10

?