Commit 554238daa1b21afb75da6bd627fa6c8f2d8f498b
1 parent
2c862ae2
Exists in
master
new file: list and set utilities
Showing
1 changed file
with
12 additions
and
0 deletions
Show diff stats
@@ -0,0 +1,12 @@ | @@ -0,0 +1,12 @@ | ||
1 | +% == No, Emacs this is -*-Prolog-*- code, not what you thought... ============= | ||
2 | + | ||
3 | +% -- utility predicates ------------------------------------------------------- | ||
4 | + | ||
5 | +% -- subset (SUB, SET, REST) -------------------------------------------------- | ||
6 | + | ||
7 | +subset(L, L, []). | ||
8 | +subset(S, [H|T], R) :- subset_aux(T, H, S, R). | ||
9 | + | ||
10 | + subset_aux(S, R, S, [R]). | ||
11 | + subset_aux([H|T], R1, S, [R1|R]) :- subset_aux(T, H, S, R). | ||
12 | + subset_aux([H|T], X, [X|S], R) :- subset_aux(T, H, S, R). |