Go to the previous, next section.
This package provides an implementation of extendable arrays with logarithmic access time.
Beware: the atom $
is used to indicate an unset element, and the
functor $ /4
is used to indicate a subtree. In general, array
elements whose principal function symbol is $
will not work.
To load the package, enter the query
| ?- use_module(library(arrays)).
| ?- new_array(A). A = array($($,$,$,$),2) ? yes
Array[Index]
is undefined.
aref/3
except that Element is a new array if
Array[Index]
is undefined. Example:
| ?- arefa(3, array($($,$,$,$),2), E). E = array($($,$,$,$),2) ? yes
aref/3
except that Element is []
for undefined
cells. Example:
| ?- arefl(3, array($($,$,$,$),2), E). E = [] ? yes
| ?- array_to_list(array($(a,b,c,d),2), List). List = [0-a,1-b,2-c,3-d] ? yes
Array[Index]
to Element. Example:
| ?- aset(3,array($($,$,$,$),2), a, Newarr). Newarr = array($($,$,$,a),2) ? yes
Go to the previous, next section.