|
GVarName | ::= | atom |
atom(Index,...,Index) | ||
Index | ::= | integer |
GVarName |
|
GVarName is a variable | instantiation_error | ||
GVarName is neither a variable nor a callable term | type_error(callable, GVarName) | ||
GVarName is a compound term and a sub-argument E is not a valid index (section 6.21) | domain_error(g_array_index, E) | ||
|
GVarName is a variable | instantiation_error | ||
GVarName is neither a variable nor a callable term | type_error(callable, GVarName) | ||
GVarName is a compound term and a sub-argument E is not a valid index (section 6.21) | domain_error(g_array_index, E) | ||
|
GVarName is a variable | instantiation_error | ||
GVarName is neither a variable nor a callable term | type_error(callable, GVarName) | ||
GVarName is a compound term and a sub-argument E is not a valid index (section 6.21) | domain_error(g_array_index, E) | ||
Size is neither a variable nor an integer | type_error(integer, Size) | ||
|
inc(Var, Value) :- g_read(Var, Value), X is Value+1, g_assign(Var, X).
test(Old) :- | testb(Old) :- | |
g_assign(x,1), | g_assign(x,1), | |
( g_read(x, Old), | ( g_read(x, Old), | |
g_assign(x, 2) | g_assignb(x, 2) | |
; g_read(x, Old), | ; g_read(x, Old), | |
g_assign(x, 3) | g_assign(x, 3) | |
). | ). |
test(B) :- | test(B) :- | |
g_assign(b, f(X)), | g_link(b, f(X)), | |
X=12, | X=12, | |
g_read(b, B). | g_read(b, B). |
| ?- g_assign(w, g_array(3)), g_read(w, X). X = g_array([0,0,0]) | ?- g_assign(w(0), 16), g_assign(w(1), 32), g_assign(w(2), 64), g_read(w, X). X = g_array([16,32,64])
| ?- g_assign(k, g_array([16,32,64])), g_read(k, X). X = g_array([16,32,64]) | ?- g_assign(k, g_array(3,null)), g_read(k, X), g_array_size(k, S). S = 3 X = g_array([null,null,null])
| ?- g_assign(w, g_array(2, g_array(3))), g_read(w, X). X = g_array([g_array([0,0,0]),g_array([0,0,0])]) | ?- ( for(I,0,1), for(J,0,2), K is I*3+J, g_assign(w(I,J), K), fail ; g_read(w, X) ). X = g_array([g_array([0,1,2]),g_array([3,4,5])]) | ?- g_read(w(1),X). X = g_array([3,4,5])
| ?- g_assign(w,g_array([1,2,g_array([a,b,c]), g_array(2,z),5])), g_read(w, X). X = g_array([1,2,g_array([a,b,c]), g_array([z,z]),5]) | ?- g_read(w(1), X), g_read(w(2,1), Y), g_read(w(3,1), Z). X = 2 Y = b Z = z | ?- g_read(w(1,2),X). {exception: error(domain_error(g_array_index,w(1,2)),g_read/2)}
| ?- g_assign(a, g_array([10,20,30])), g_read(a, X). X = g_array([10,20,30]) | ?- g_assign(a, g_array_extend(5,null)), g_read(a, X). X = g_array([10,20,30,null,null]) | ?- g_assign(a, g_array([10,20,30])), g_read(a, X). X = g_array([10,20,30]) | ?- g_assign(a, g_array_extend([1,2,3,4,5,6])), g_read(a, X). X = g_array([10,20,30,4,5,6])