This package provides an implementation of extendible 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(
-Array)
| ?- new_array(A). A = array($($,$,$,$),2)
is_array(
+Array)
aref(
+Index,
+Array,
?Element)
[
Index]
is undefined.
arefa(
+Index,
+Array,
?Element)
aref/3
except that Element is a new array if
Array[
Index]
is undefined. Example:
| ?- arefa(3, array($($,$,$,$),2), E). E = array($($,$,$,$),2)
arefl(
+Index,
+Array,
?Element)
aref/3
except that Element is []
for undefined
cells. Example:
| ?- arefl(3, array($($,$,$,$),2), E). E = []
array_to_list(
+Array,
-List)
| ?- array_to_list(array($(a,b,c,d),2), List). List = [0-a,1-b,2-c,3-d]
aset(
+Index,
+Array,
+Element,
-NewArray)
[
Index]
to Element. Example:
| ?- aset(3,array($($,$,$,$),2), a, Newarr). Newarr = array($($,$,$,a),2)