rxamples were broken

This commit is contained in:
Vitor Santos Costa 2016-12-05 20:49:10 -06:00
parent 4f423dc16a
commit ea72cd09e3
2 changed files with 26 additions and 18 deletions

View File

@ -4,6 +4,12 @@
:- use_module(library(matrix)). :- use_module(library(matrix)).
:- use_module(library(maplist)). :- use_module(library(maplist)).
:- initialization( main ).
main :-
forall( between(1, 13,I),
( writeln(t:xsI), atomic_concat(t,I,G), call(G) ) ).
t1 :- t1 :-
X <== matrix([1,2,3,4,5,6],[dim=[3,2]]), X <== matrix([1,2,3,4,5,6],[dim=[3,2]]),
writeln(X). writeln(X).
@ -94,15 +100,15 @@ t8 :-
t9 :- t9 :-
N1 = 1, N1 = 1,
X = array[0..N1,0..N1] of [1,2,3,4], X <== array[0..N1,0..N1] of [1,2,3,4],
Z = array[0..N1,0..N1] of _, 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]), foreach([I in 0..N1, J in I..N1], Z[I,J] <== X[I,J] - X[J,I]),
O <== list(Z), O <== list(Z),
writeln(O). writeln(O).
t10 :- t10 :-
N1 = 1, N1 = 1,
X = array[0..N1,0..N1] of 1:4, X <== array[0..N1,0..N1] of 1:4,
O <== list(X-2), O <== list(X-2),
writeln(O), writeln(O),
O1 <== list(X)+2, O1 <== list(X)+2,
@ -112,7 +118,7 @@ t10 :-
t11 :- t11 :-
N = 3, N = 3,
X = array[1..N,1..N] of 1:9, X <== array[1..N,1..N] of 1:9,
O <== X[1,1], O <== X[1,1],
writeln(O), writeln(O),
O1 <== X[2,_], O1 <== X[2,_],
@ -123,7 +129,7 @@ t11 :-
t12 :- t12 :-
N = 8, N = 8,
N2 is N*N, N2 is N*N,
X = array[N,N] of 1:N2, X <== array[N,N] of 1:N2,
N1 is N-1, N1 is N-1,
foreach([I in 0..N1, J in 0..N1], plus(X[I,J]), 0, AccF), foreach([I in 0..N1, J in 0..N1], plus(X[I,J]), 0, AccF),
writeln(sum=AccF). writeln(sum=AccF).
@ -131,9 +137,12 @@ t12 :-
t13 :- t13 :-
N = 2, N = 2,
N2 is N*N, N2 is N*N,
X = array[1..N,1..N] of 1:N2, X <== array[1..N,1..N] of 1:N2,
Y = array[1..N,1..N] of _, Y <== array[1..N,1..N] of _,
Y[1,_] <== X[_,1], Y[1,_] <== X[_,1],
L <== list(Y), LX <== list(X),
writeln(out=L). LY <== list(Y),
writeln('x'=LX),
writeln('y'=LY),
fail.
t13.

View File

@ -18,17 +18,16 @@
* @file matrix.yap * @file matrix.yap
* @author VITOR SANTOS COSTA <vsc@VITORs-MBP.lan> * @author VITOR SANTOS COSTA <vsc@VITORs-MBP.lan>
* @date Tue Nov 17 22:53:40 2015 * @date Tue Nov 17 22:53:40 2015
* *
* @brief Vector, Array and Matrix library * @brief Vector, Array and Matrix library
* *
* *
*/ */
:- module( matrix, :- 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, in),
op(700, xfx, ins), op(700, xfx, ins),
op(450, xfx, ..), % should bind more tightly than \/ 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_. _Position_.