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