return to tranceaddict TranceAddict Forums Archive > Other > Technology & Gadget Zone

 
anyone knows prolog?
View this Thread in Original format
3xx3r7
here's a problem.

i have a list of facts like this:

fact(x, y).
fact(b, a).
fact(d, c).
fact(z, q).

i need to write a predicate where i input a list of first items and it will spit out a list of corresponding second items, e.g. pred(X, [x, d]). would output X = [y, c].

also, it should be bidirectional, i.e. pred([y, q, a], X). spits out X = [x, z, b].

so far i have is the basic list behaviour:

member(X, [X|Y]).
member(X, [B|Y]) :- member (X,Y).
Mmanu
malek
man I wish you asked me this question like 5 years ago, we were doing some Prolog at university!

Very intresting language, I kind of liked it.

but now i'm old and my memory is gone :(
CLICK TO RETURN TO TOP OF PAGE
 
Privacy Statement