Exception Handling | categories Lists, Sets and Instructions array |
Methods and Types Methods |
An array can be seen as a fixed-size list, with a member type (the slot name is of), which tells the type of all the members of the array. Because of the fixed size, the compiler is able to generate faster code than when using lists, so lists should be used when the collection shrinks and grows, and an array may be used otherwise. This is especially true for arrays of floats, which are handled in a special (and efficient) way by the compiler.
Arrays are simpler than lists, and only a few operations are supported. Therefore, more complex operations such as append often require a cast to list (list!). An array is created explicitly with the make_array property :
let l := make_array(10,float,0.0) in l[1] := l[3] + l[4] |
categories | array | normal dispatch | Kernel method |
creates a copy of the bag x that is represented as an array. The member type must be given as a parameter t and an error will occur if a member of the bag does not belong to t..
categories | array | normal dispatch | Kernel method |
The copy of an array returns a fresh array with the same elements
categories | array | normal dispatch | Kernel method |
get(a, x) returns the lowest i such that a[i] = x (if no such i exists, 0 is returned).
categories | array | normal dispatch | Kernel method |
returns the length of an array
categories | array | normal dispatch | Kernel method |
list!(a) transforms a into a list.
categories | array | normal dispatch | Core method |
returns an array of length n filled with x. The parameter t is the member_type of the array, thus x must belong to t, as well as any future value that will be put in the array.
categories | array | normal dispatch | Kernel method |
member_type(x) returns the type of all members of the array x. Therefore, member(a) = member_type(a) for an array a.
categories | array | inline | Kernel method |
nth(a,i) returns the ithelement of the array a. nth(a,i) is equivalent to a[i].
categories | array | normal dispatch | Kernel method |
nth=(a,i,x) replace the ithelement of the array a by x. nth(a,i,x) is equivalent to a[i] := x.