Arrays: Difference between revisions

Added array description
(Added array description)
Line 4,230:
li $v0, 10 # end program
syscall
</lang>
 
=={{header|MiniScript}}==
Lists and arrays are synonymous in MiniScript.
 
Operations:
<pre>
+ list concatenation
* replication (i.e. repeat the list some number of times)
/ division (get some fraction of a list)
==, != comparison (for equality)
[i] get/set item i (first item is 0)
[i:j] get sublist ("slice") from i up to j
</pre>
 
Slicing:
<pre>
x[0] "a" (first item)
x[1] 42 (second item)
x[-1] "hike" (last item)
x[-2] 7 (next-to-last item)
x[1:-1] [42, 3.14, 7] (everything from the second up to the last item)
x[1:] [42, 3.14, 7, "hike"] (everything from the second item to the end)
x[:-1] [42, 3.14, 7, "hike"] (everything up to the last item)
</pre>
<lang MiniScript>arr = ["a", 1, 3]
print arr[0]
 
arr.push("x")
print arr.pop()
</lang>