TranceAddict Forums

TranceAddict Forums (www.tranceaddict.com/forums)
- Technology & Gadget Zone
-- anyone knows prolog?


Posted by 3xx3r7 on Apr-10-2007 18:04:

anyone knows prolog?

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).


Posted by Mmanu on Apr-15-2007 00:39:


Posted by malek on Apr-15-2007 07:45:

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



Powered by: vBulletin
Copyright © 2000-2021, Jelsoft Enterprises Ltd.