On 03/05/2013 05:44, Sergii Dymchenko wrote: ... > > Maybe there are some complicated reasons why working syntax is "7 is A[1]" and not "A[1] is 7"? > Maybe it's not too hard to make "A[1] is 7" work in future ECLiPSe releases? The is/2 predicate is not symmetric. It accepts and evaluates expressions on its right hand side only, and unifies the result with the (unevaluated) left hand side. The array subscript notation A[1] is considered an expression, and is therefore only evaluated when it occurs on the right hand side. In other words, the reason for "A[1] is 7" not working is the same as for "3+4 is 7" not working. It is probably not a good idea to modify the rather clean definition of is/2. If you use constraints anyway, why not use #=/2 (as you said). Alternatively, define your own "assignment" operator: :- op(700, xfx, :=). subscript(A,I) := X :- subscript(A, I, X). ?- dim(A,[3]), A[3] := 7. A = [](_328, _329, 7) Yes (0.00s cpu) -- JoachimReceived on Sat May 04 2013 - 17:35:51 CEST
This archive was generated by hypermail 2.2.0 : Sun May 05 2013 - 06:13:46 CEST