Nov 17, 2002 #1 YZzzz Programmer Nov 17, 2002 1 GB Hi, Given the fact p(a,X,Z) and List= [e,f], how can i create its expansion which is the set of [p(a,e,e),p(a,e,f),p(a,f,e),p(a,f,f)] Thanks
Hi, Given the fact p(a,X,Z) and List= [e,f], how can i create its expansion which is the set of [p(a,e,e),p(a,e,f),p(a,f,e),p(a,f,f)] Thanks
Nov 22, 2002 #2 baile Technical User Nov 22, 2002 2 CA Hi, Even though this is not an elligant solution, but it works. Here u go. expand(p(A,B,C),List,Result):-setof([p(A,B,C)], exp(p(A,B,C), List),Result). exp(p(A,B,C),List):-member(B,List),member(C,List). ?- List=[e,f],expand(p(a,X,Z),List,Result). List = [e, f] X = _G167 Z = _G168 Result = [[p(a, e, e)], [p(a, e, f)], [p(a, f, e)], [p(a, f, f)]] Yes Upvote 0 Downvote
Hi, Even though this is not an elligant solution, but it works. Here u go. expand(p(A,B,C),List,Result):-setof([p(A,B,C)], exp(p(A,B,C), List),Result). exp(p(A,B,C),List):-member(B,List),member(C,List). ?- List=[e,f],expand(p(a,X,Z),List,Result). List = [e, f] X = _G167 Z = _G168 Result = [[p(a, e, e)], [p(a, e, f)], [p(a, f, e)], [p(a, f, f)]] Yes