1 :-use_module(library(clpfd)).
4 % N is the dot product of lists V1 and V2.
5 dot(V1, V2, N) :- maplist(product,V1,V2,P), sumlist(P,N).
6 product(N1,N2,N3) :- N3 is N1*N2.
8 % Matrix multiplication with matrices represented
9 % as lists of lists. M3 is the product of M1 and M2
10 mmult(M1, M2, M3) :- transpose(M2,MT), maplist(mm_helper(MT), M1, M3).
11 mm_helper(M2, I1, M3) :- maplist(dot(I1), M2, M3).
16 suml(L1,L2,[E1 + E2|R2]):-
31 flatten(List, Flattened):-
32 flatten(List, [], Flattened).
34 flatten([], Flattened, Flattened).
35 flatten([Item|Tail], L, Flattened):-
36 flatten(Item, L1, Flattened),
38 flatten(Item, Flattened, [Item|Flattened]):-
68 X=[[A,B,C,0],[F,E,0,G],[H,0,I,J],[0,K,L,M]],
89 label([A,B,C,F,E,G,H,I,J,K,L,M]),
91 open('res2.txt',append,Stream),
104 findall(X,bistoc(X),L),
107 write('but : '),writeln(DT).