summaryrefslogtreecommitdiff
path: root/prolog/problems/sets/union_3/common.py
blob: bd77d3a68d0a35f73cd3d2b42a691a22cb78f4e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# coding=utf-8

id = 128
group = 'sets'
number = 35
visible = True
facts = None

solution = '''\
memb128(X, [X|_]).
memb128(X, [_|T]) :-
  memb128(X, T).

union([], S2, S2).
union([H|T], S2, [H|U]) :-
  \+ memb128(H, S2),
  union(T, S2, U).
union([H|T], S2, U) :-
  memb128(H, S2),
  union(T, S2, U).
'''