I have a list of pairs and want to find the element with the corresponding first value.
?- findconn1(9, [(9,[23,33]),(42,[21,322])], R).
So in this case I want the result to be (9,[23,23])
in R
.
The code is
findconn(X, [], R).
findconn(X, [(H,T)|Y], R) :-
member(X, H),
findConn(X, Y),
append(T, T, R).
It always returns false
despite that the element is present. And also is there any other way to return as I'm quite new to Prolog.
member/2
, use pattern matching. – Luai Ghunimmember/2
... – repeat