Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chapter 11 Subset check fix #48

Open
nicoabie opened this issue Apr 6, 2019 · 0 comments
Open

Chapter 11 Subset check fix #48

nicoabie opened this issue Apr 6, 2019 · 0 comments

Comments

@nicoabie
Copy link

nicoabie commented Apr 6, 2019

Hi,
The solution provided will asset that subset([a,b,c,a], [a, b, c]). is true.
It is missing checking that the first parameter is a set itself.
Here I propose a fix using the set definition implemented in a previous chapter.

set([], []).
set([H|T], X):- member(H, T), !, set(T, X).
set([H|T], [H|X]):- set(T, X).

subset_check(SS, S):-
  set(SS, SS),
  all_members(SS, S).

all_members([], _).
all_members([H|T], S):-
  member(H, S),
  !,
  all_members(T, S)

Thanks a lot for making this repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant