Vectors are the closest approximation Muq offers to cheap, pure,
minimal-overhead chunks of storage with which you can do what
you please with minimum hindrance (or assistance). They consist
of n
slots numbered 0
to n-1
.
root: "abc" 4 makeVector --> v v length root: 4 pop root: v ls 0 "abc" 1 "abc" 2 "abc" 3 "abc" root: "def" --> v[0] root: v ls 0 "def" 1 "abc" 2 "abc" 3 "abc" root: for i from 0 below 4 do{ v[i] , "\n" , } def abc abc abc root:
All the Index facilities work with vectors, except that they are
restricted to always having keys restricted to the consecutive
sequence 0 -> n-1
. Vectors may point to other vectors
(or anything else) in arbitrary trees and graphs.
As with all other Muq objects, vectors are automatically recycled when they are no longer accessible: You need not (and cannot) explicitly free them. (You also cannot have C-style memory leaks or pointer bugs!)
Vectors are currently limited to about 64K in length; Each slot is eight bytes (64 bits) so that gives you about eight thousand slots.
Here's a shortcut for creating a vector with given contents:
root: [ "abc" "def" "ghi" | ]vec root: #<vec> ls 0 "abc" 1 "def" 2 "ghi" root:
Go to the first, previous, next, last section, table of contents.