As @lurker says in his comment, you are trying to apply subscript/3
to a list, but it expects an array or any other flat structure.
By convention, ECLiPSe
uses structures with the functor '[]'/N
for arrays. You can create them either by writing them literally
Array = [](5,Y,Z,9,2)
or by creating them with dim/2
dim(Array, [5])
or by converting them from a list
array_list(Array, [5,Y,Z,9,2])
On such arrays, subscript/3
works as expected:
?- Array = [](5,X,Z,9,2), subscript(Array,[4],Elem).
Elem = 9
Yes (0.00s cpu)
Note that subscript/3
is implicitly called when you use array notation inside an arithmetic expression:
?- Array = [](5,X,Z,9,2), Result is Array[4] + 1.
Result = 10
Yes (0.00s cpu)