Skip to content

Chapter 11 Subset check fix #48

Open
@nicoabie

Description

@nicoabie

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions