After writing my first answer, I realized that you can also simplify your program using findall row(Row, Matrix, L) :- findall(X,cell(_,Row,Matrix,X),L).
After trying this, I got an uncaught exception: error(instantiation_error,(is)/2) . I'm adding a link to the complete code in the original post – kikito Oct 17 at 21:48 1 The exception means, that you use is without a fully instantiated right hand side. And that is because in my findall I use a variable (the underscore).
The findall doesn't work if you do arithmetic with the input. You could rewrite cell to use recursion or you could use the approach I proposed in my other answer – Joe Lehmann Oct 17 at 22:28 I'm sorry I didn't get back to this before. Thanks for your feedback, it was all I needed.
– kikito Oct 24 at 18:37.
I would think about changing the representation to a list of lists rather than a flat list, then selecting a row becomes very easy. You can just use the built-in nth1/3: :- use_module(library(lists)). % I use Sicstus Prolog row(N,M,X) :- nth1(N,M,X).
Cell(R,C,M,X) :- nth1(R,M,Y), nth1(C,Y,X). Column(N,M,X) :- findall(Y,(nth1(_,M,Z), nth1(N,Z,Y)),X). M(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16).
Example(Row,Cell,Column) :- m(M), row(2,M,Row), cell(2,3,M,Cell), column(2,M,Column). %|? - example(A,B,C).
%A = 5,6,7,8, %B = 7, %C = 2,6,10,14? ; %no.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.