I need to get some values of facts. That part seems to be working.
fact1(A, _, Val1, _, _),
fact2(_, B, Val2, _, _),
A = B,
But as soon as I try to append these values [(Val1,Val2)]
to the List(OutList) by using the append/3 predicate, I only get one possible solution back instead of a list with all of them.
Appending like this: append(OutList, [(Val1,Val2)], OutList)
doesn't work either. I feel like I am missing something fundamental here.
This is what my predicate looks like so far.
buildList(OutList):-
fact1(A, _, Val1, _, _),
fact2(_, B, Val2, _, _),
A = B,
append([], [(Val1,Val2)], OutList).
Can someone point me to some mistakes I have made. I know the problem is probably pretty easy to find but I am just starting out with Prolog/functional programming.
Edit: If I had fact1(a,b,c,d,e).
and fact2(f,a,g,h,i)
, then I'd want my predicate to give me a list of all fact2
3rd place value and fact1
third place values as a tuple, where the a
matches up with fact1
. I have kind of a hard time explaining it, sorry.