Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

subset predicate to match a list of terms

Status
Not open for further replies.

Lanko

Programmer
Dec 3, 2003
1
GB
Hi,
subset predicate is mostly performed for two lists that consist of atoms like X = [1,2,4] & Y =[1,2,4,5,6]. By having the query , subset(X,Y), it should return true. What happens if for example , X=[1,2] & Y = [first(1,2,3),first(3,5,6),first(4,5,8)]. For which all elements in X must match with the first two element of Y. In the example stated above. X = [1,2] & first(1,2,3) should match. How should I modify the standard subset code to suit the above purpose. Thanks.


subset([], []).
subset([_|A],B ):- subset(A, B).
subset([Z|A],[Z|B]):- subset(A, B).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top