The main use for this predicate is to provide array syntax in arithmetic expressions. Consider the arithmetic expression
X is Mat[I,J] + 1which the ECLiPSe parser parses as
X is subscript(Mat,[I,J]) + 1and the arithmetic evaluation mechanism turns that into
subscript(Mat,[I,J],T), +(T,1,X)If Subscript contains a range of the form From..To, then this results in the retrieval of a list of elements with the indices from From to To.
[eclipse 6]: subscript(s(t(a,b),t(c,d),t(e,f)), [3,2], X). X = f yes. [eclipse 11]: Vector = v(12,13,14,15), X is Vector[3]. X = 14 Vector = v(12, 13, 14, 15) yes. [eclipse 12]: Matrix = m(r(1,2,3),r(4,5,6),r(7,8,9)), X is Matrix[2,1]. X = 4 Matrix = m(r(1, 2, 3), r(4, 5, 6), r(7, 8, 9)) yes. [eclipse 18]: Matrix = m(r(1,2,3),r(4,5,6),r(7,8,9)), Row is Matrix[2]. Row = r(4, 5, 6) Matrix = m(r(1, 2, 3), r(4, 5, 6), r(7, 8, 9)) yes. [eclipse 5]: Matrix = m(r(1,2,3),r(4,5,6),r(7,8,9)), subscript(Matrix, [2,1..3], Row), subscript(Matrix, [1..3,2], Col), subscript(Matrix, [2..3,1..2], Sub). Matrix = m(r(1, 2, 3), r(4, 5, 6), r(7, 8, 9)) Row = [4, 5, 6] Col = [2, 5, 8] Sub = [[4, 5], [7, 8]] yes.