Array Type

Arrays are integer indexed collections of references to values.

The supplied index, index, can be negative in which case the calculated index is array-length + index.

Reader Form

Arrays of simple types can be constructed with the reader form

#[ [value ...] ]

degenerating to #[].

Any value will not be evaluated, only simple type construction (numbers, strings, symbols etc.) will occur.

Array Predicates

function array? o

test if o is an array

Param o:

object to test

Return:

#t if o is an array, #f otherwise

Array Constructors

function make-array size [default]

create an array with an initial allocation size of size

Param size:

initial array size

Type size:

integer

Param default:

default array element value, defaults to #f

Type default:

value, optional

Return:

the new array

Rtype:

array

function copy-array orig [depth [extra]]

copy array orig and add an optional extra elements

Param orig:

initial array

Type orig:

array

Param depth:

'shallow or 'deep (default)

Type depth:

symbol, optional

Param extra:

how many extra elements, defaults to 0 (zero)

Type extra:

integer, optional

Return:

the new array

Rtype:

array

function list->array l

convert list l to an array

Param l:

list to be converted

Type l:

list

Return:

array

Rtype:

array

function array [x]

construct an array from x

Param x:

elements for the array

Type x:

list

Return:

array constructed from the elements of x

Rtype:

array

this simply calls list->array

Array Attributes

function array-length a

return the used length of a

Param a:

the array

Type a:

array

Return:

the length of the array

Rtype:

integer

The used length is the highest accessed index plus one

function array-ref a index

return the value at index of a

Param a:

the array

Type a:

array

Param index:

index

Type index:

integer

Return:

the value at index of the array

Rtype:

integer

Raises:

^rt-array-bounds-error

function array-set! a index v

set the index of a to v

Param a:

the array

Type a:

array

Param index:

index

Type index:

integer

Param v:

value

Type v:

any

Return:

#<unspec>

Raises:

^rt-array-bounds-error

Array Functions

function array-push! a v

append v to a

Param a:

the array

Type a:

array

Param v:

value

Type v:

any

Return:

#<unspec>

Raises:

^rt-array-bounds-error

Treats a as a stack and appends v to the end

function array-pop! a

pop the last value off a

Param a:

the array

Type a:

array

Return:

value

Rtype:

any

Raises:

^rt-array-bounds-error

Treats a as a stack and pops a value off the end

function array-unshift! a v

unshifts v onto a

Param a:

the array

Type a:

array

Param v:

value

Rtype:

any

Return:

#<unspec>

Treats a as a stack and unshifts (prepends) v to the start

function array-shift! a

shifts the first value off a

Param a:

the array

Type a:

array

Return:

value

Rtype:

any

Treats a as a stack and shifts a value off the start

function array-fill! a fill

set all the elements of a to fill

Param a:

the array to fill

Type a:

array

Param fill:

value to use for fill

Type fill:

any

Return:

#<unspec>

function array-find-eq? a v [index]

return the first index of v in a starting at index or -1

Param a:

the array

Type a:

array

Param v:

the value to search for

Type v:

any

Param index:

starting index, defaults to 0

Type index:

integer, optional

Return:

the index of the first v in a

Rtype:

integer

Raises:

^rt-array-bounds-error

function array-for-each-set a func

call func for each element in array a with a non-default value with arguments: index the value at that index

Param a:

array

Type a:

array

Param func:

func to be called with each index, value tuple

Type func:

2-ary function

Return:

#<unspec>

function fold-array a func val

call func for each element in array a with arguments: index, the value at that index and val

val is updated to the value returned by func.

The final value of val is returned.

Param a:

array

Type a:

array

Param func:

func to be called with each index, value, val tuple

Type func:

3-ary function

Param val:

initial value for val

Type val:

any

Return:

final value of val

Rtype:

any

Last built at 2024-12-21T07:10:43Z+0000 from 62cca4c (dev) for Idio 0.3.b.6