1

This code can not get me subsets it's always giving false as a result

possibleSubset([], []).
possibleSubset([H|T], [H|NT]):-
            possibleSubset(T, NT).
possibleSubset([_|T], NT):-
            possibleSubset(T, NT).

what to do then ? I have a project and I must submit it tomorrow so please help me as fast as you can

Jy2500
  • 21
  • 1
  • 4
  • Am I correct in supposing that instead of `possibleSubset/2`, this predicate should be called `is_leftlist_a_subset_of_rightlist/2` and the list are not ordered in any way as in [ordsets](https://www.swi-prolog.org/pldoc/man?section=ordsets)? – David Tonhofer Apr 10 '20 at 07:47
  • Meanwhile, have a look at this question: [Subsets in Prolog](https://stackoverflow.com/questions/4912869/subsets-in-prolog) – David Tonhofer Apr 10 '20 at 07:59
  • Nice topic but in fact I took the code from there and also it was working day a go but now it doesnt work – Jy2500 Apr 10 '20 at 08:20
  • @AnasAshrad Well, it obviously doesn't work (just by reading it once) but what changed between a day ago and now? Do you have the code that worked? – David Tonhofer Apr 10 '20 at 09:02
  • Please provide some data that is `false` where you expect this to be `true`. – Willem Van Onsem Apr 10 '20 at 10:38
  • It should act like this ?- subset([1,2,3], X). X = [] ; X = [1] ; X = [2] ; X = [3] ; X = [1, 2] ; X = [1, 2, 3] ; X = [2, 3] ; ... It was working perfectly a day ago like I said and I didnt change a single thing in it except the name of it...I think this should not make a problem – Jy2500 Apr 11 '20 at 00:10

0 Answers0