Download code

Jump to: navigation, search

Back to Determinate_(Prolog)

Download for Windows: single file, zip

Download for UNIX: single file, zip, tar.gz, tar.bz2

determinate.pl

 1 vget([X|_], 0, X).
 2 vget([_|T], I, X) :-
 3 	I > 0,
 4 	I1 is I-1,
 5 	vget(T, I1, X).
 6 
 7 mget([H|_], 0, J, X) :-
 8 	vget(H, J, X).
 9 mget([_|T], I, J, X) :-
10 	I > 0,
11 	I1 is I - 1,
12 	mget(T, I1, J, X).
13 
14 numberOfRows(Matrix, Rows) :-
15 	length(Matrix, Rows).
16 
17 numberOfColumns([Vector|_], Columns) :-
18 	length(Vector, Columns).
19 
20 determinate(Matrix, Determinate) :-
21 	numberOfRows(Matrix, Rows),
22 	numberOfColumns(Matrix, Columns),
23 	Rows = 2,
24 	Columns = 2,
25 	mget(Matrix, 0, 0, A),
26 	mget(Matrix, 0, 1, B),
27 	mget(Matrix, 1, 0, C),
28 	mget(Matrix, 1, 1, D),
29 	Determinate is A * D - B * C.
30 
31 


hijacker
hijacker
hijacker
hijacker