Matrix transposition

Description

Matrix translation

Source: PROLOG str. 203 Wydawnictwo PLJ Warszawa 1991 ISBN 83-85190-63-5

Download

Program source code: matrix_transposition.pl

Listing

transp(A, B) :- dlug(A, N), pusta(N, T, 0), t2(A, T, B).
 
t1([X|Y], [G|O], [Z|U]) :- append(G, [X], Z), t1(Y, O, U), !.
t1([], [], []) :- !.
t2([L1|G1], L, V) :- t1(L1, L, K), t2(G1, K, V), !.
t2([], L, L).
dlug([G|_], N) :- d11(G, 0, N).
d11([], X, X).
d11([_|T], I, N) :- J is I + 1, d11(T, J, N).
 
pusta(N, [], N).
pusta(J, [[]|O], I) :- Jn is I + 1, pusta(J, O, Jn), !.
 
test :- transp([[3, 8, -4], [5, -2, 4]], T)

Comments

pl/prolog/pllib/matrix_transposition.txt · ostatnio zmienione: 2017/07/17 08:08 (edycja zewnętrzna)
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0