Next: , Previous: , Up: arrays   [Index]


34.2 Array item positions

A single element position in a multidimensional array is described by a position object; position objects are disjoint from all the other Scheme objects.

The following bindings are exported by the library (vicare containers arrays). Bindings prefixed by $ are unsafe operations: they do not validate their arguments.

Constructors

Function: position coord0 coord
Function: $position coord0 coord

Build and return a new multidimensional array position object containing the specified coordinates.

Function: make-position dim
Function: $make-position dim

Build and return a new multidimensional array position object of the specified dimension containing all 0 as coordinates.

Function: vector->position vec
Function: $vector->position vec

Build and return a new multidimensional array position object having the items in the given vector argument as coordinates.

Function: list->position ell
Function: $list->position ell

Build and return a new multidimensional array position object having the items in the given proper list argument as coordinates.

Function: position-copy pos
Function: $position-copy pos

Build and return a copy of the position object pos.

Predicates

Function: position? obj

Return #t if obj is a position object; otherwise return #f.

Function: position-index? pos obj
Function: $position-index? pos obj

Return #t if obj is a valid index to select a coordinate in the position object pos; otherwise return #f.

With position-index?: it is an error if pos is not a position object. With $position-index?: the argument pos is not validated befor accessing it as position object.

Accessors and mutators

Function: position-dimension pos
Function: $position-dimension pos

Return the number of coordinates of the element position object pos.

Function: position-ref pos idx
Function: $position-ref pos idx

Return the coordinate at index idx in the position object pos.

Function: position-set! pos idx coord
Function: $position-set! pos idx coord

Store a new coordinate coord at index idx in the position object pos

Comparison functions

Function: position=? pos0 pos
Function: $position=? pos1 pos2

Return #t if all the arguments are position objects and their coordinates are equal.

Arguments validation

The following bindings are validation clauses to be used with the facilities of the library (vicare arguments validation).

Validation Clause: position obj
Validation Clause: position/false obj

Succeed if obj is a position object; the second clause accepts also #f.

Validation Clause: position-index pos obj

Assuming pos is a position object (this argument is not validated): succeed if obj is a valid index to select a coordinate in pos.

Validation Clause: list-of-positions obj

Succeed if obj is a proper list of items, each being a multidimensional array position object.


Next: , Previous: , Up: arrays   [Index]