Jump to content

Arrays: Difference between revisions

Added XLISP
mNo edit summary
(Added XLISP)
Line 5,286:
Arrays in assembly are a reference to anything, from groups of data such as f/uArray to strings like _msg's or sArray.
Mutlidimentional arrays don't exist in assembly. To make a reference to one from assembly, we use a format as such. "row * r_len + column * member_size".
 
=={{header|XLISP}}==
Like some other languages, XLISP refers to one-dimensional arrays as vectors. Examples of vector and array syntax, from a REPL (interactive session):
<lang scheme>[1] (define a (make-vector 10)) ; vector of 10 elements initialized to the empty list
 
A
[2] (define b (make-vector 10 5)) ; vector of 10 elements initialized to 5
 
B
[3] (define c #(1 2 3 4 5 6 7 8 9 10)) ; vector literal
 
C
[4] (vector-ref c 3) ; retrieve a value -- NB. indexed from 0
 
4
[5] (vector-set! a 5 1) ; set a_5 to 1
 
1
[6] (define d (make-array 5 6 7)) ; 3-dimensional array of size 5 by 6 by 7
 
D
[7] (array-set! d 1 2 3 10) ; set d_1,2,3 to 10 -- NB. still indexed from 0
 
10
[8] (array-ref d 1 2 3) ; and get the value of d_1,2,3
 
10</lang>
 
=={{header|XPL0}}==
519

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.