I have to representing a matrix as a list of the matrix rows with the term
like this [[a,b],[c,d]]
with representing numbers in Peano notation.
I have to obtain a row of matrix
ow(X,N,C)
: C is the N-th row of matrix X. and the column of matrix
column(X,N,C)
: C es the N-th column of matrix X.
alse this One to decompose a matrix in its first column and the rest of the matrix (which is exactly the same matrix but without the first column):
first_column(X,C,R): matrix X is formed by a first column C in
front of matrix R.
Could somebody help me?
Peano' notation simplifies expressing recursive algorithms. I assume matrix indexing is 0 based, and will show you how to get the simplest task of your assignment.
row([Row|_], 0, Row).
row([_|Rows], succ(N), Row) :- row(Rows, N, Row).
test (get the second row, with index 1):
?- row([[a,b], [c,d]], succ(0), R).
R = [c, d] ;
false.
This shows the essential ingredients you'll use to answer the other two tasks.