From ea72cd09e31dd06f9d4edd4062a2d2b08ec6141b Mon Sep 17 00:00:00 2001 From: Vitor Santos Costa Date: Mon, 5 Dec 2016 20:49:10 -0600 Subject: [PATCH] rxamples were broken --- library/examples/mat.yap | 29 +++++++++++++++++++---------- library/matrix.yap | 15 +++++++-------- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/library/examples/mat.yap b/library/examples/mat.yap index 839112647..c247ab911 100644 --- a/library/examples/mat.yap +++ b/library/examples/mat.yap @@ -4,6 +4,12 @@ :- use_module(library(matrix)). :- use_module(library(maplist)). +:- initialization( main ). + +main :- + forall( between(1, 13,I), + ( writeln(t:xsI), atomic_concat(t,I,G), call(G) ) ). + t1 :- X <== matrix([1,2,3,4,5,6],[dim=[3,2]]), writeln(X). @@ -94,15 +100,15 @@ t8 :- t9 :- N1 = 1, - X = array[0..N1,0..N1] of [1,2,3,4], - Z = array[0..N1,0..N1] of _, + X <== array[0..N1,0..N1] of [1,2,3,4], + Z <== array[0..N1,0..N1] of _, foreach([I in 0..N1, J in I..N1], Z[I,J] <== X[I,J] - X[J,I]), O <== list(Z), writeln(O). t10 :- N1 = 1, - X = array[0..N1,0..N1] of 1:4, + X <== array[0..N1,0..N1] of 1:4, O <== list(X-2), writeln(O), O1 <== list(X)+2, @@ -112,7 +118,7 @@ t10 :- t11 :- N = 3, - X = array[1..N,1..N] of 1:9, + X <== array[1..N,1..N] of 1:9, O <== X[1,1], writeln(O), O1 <== X[2,_], @@ -123,7 +129,7 @@ t11 :- t12 :- N = 8, N2 is N*N, - X = array[N,N] of 1:N2, + X <== array[N,N] of 1:N2, N1 is N-1, foreach([I in 0..N1, J in 0..N1], plus(X[I,J]), 0, AccF), writeln(sum=AccF). @@ -131,9 +137,12 @@ t12 :- t13 :- N = 2, N2 is N*N, - X = array[1..N,1..N] of 1:N2, - Y = array[1..N,1..N] of _, + X <== array[1..N,1..N] of 1:N2, + Y <== array[1..N,1..N] of _, Y[1,_] <== X[_,1], - L <== list(Y), - writeln(out=L). - \ No newline at end of file + LX <== list(X), + LY <== list(Y), + writeln('x'=LX), + writeln('y'=LY), + fail. +t13. diff --git a/library/matrix.yap b/library/matrix.yap index 524abd8fd..ae7d9f206 100644 --- a/library/matrix.yap +++ b/library/matrix.yap @@ -18,17 +18,16 @@ * @file matrix.yap * @author VITOR SANTOS COSTA * @date Tue Nov 17 22:53:40 2015 - * + * * @brief Vector, Array and Matrix library - * - * + * + * */ - :- module( matrix, - [(<==)/2, op(800, xfx, '<=='), - (+=)/2, op(800, xfx, '+='), - (-=)/2, op(800, xfx, '-='), + [(<==)/2, op(800, xfx, <==), + (+=)/2, op(800, xfx, +=), + (-=)/2, op(800, xfx, -=), op(700, xfx, in), op(700, xfx, ins), op(450, xfx, ..), % should bind more tightly than \/ @@ -322,7 +321,7 @@ all elements of a matrix or list -Add _Operand_ to the element of _Matrix_ at position + Add _Operand_ to the element of _Matrix_ at position _Position_.