progress with matrix package

This commit is contained in:
Vitor Santos Costa
2013-09-19 17:59:37 +01:00
parent ab4a6c0ae3
commit 28ff95f8de
2 changed files with 70 additions and 13 deletions

View File

@@ -2,6 +2,28 @@
:- use_module(library(matrix)).
t1 :-
X <== matrix([1,2,3,4,5,6],[dims=[3,2]]),
X <== matrix([1,2,3,4,5,6],[dim=[3,2]]),
writeln(X).
t2 :-
length(L, 10),
X <== matrix(L, [dim=[2,5]]),
writeln(X).
t3 :-
numbers(1, 100, L),
X <== matrix(L, [dim=[10,10]]),
Y <== X[1..2+3,_],
writeln(Y).
t4 :-
numbers(1, 100, L),
X <== matrix(L, [dim=[10,10]]),
X1 <== matrix(X[1..2+3,_], [dim=[2,10]]),
Y <== [size=size(X1),max=max(X1),min=min(X1)],
writeln(Y).
numbers(I0, I1, Vals) :-
( I0 =< I1 -> Vals = [I0|MVals], I01 is I0+1, numbers(I01, I1, MVals) ;
Vals = [] ).