From 554238daa1b21afb75da6bd627fa6c8f2d8f498b Mon Sep 17 00:00:00 2001 From: Salvador Abreu Date: Wed, 15 Jul 2015 15:18:01 +0900 Subject: [PATCH] new file: list and set utilities --- fz/util.pl | 12 ++++++++++++ 1 file changed, 12 insertions(+), 0 deletions(-) create mode 100644 fz/util.pl diff --git a/fz/util.pl b/fz/util.pl new file mode 100644 index 0000000..4fcbeda --- /dev/null +++ b/fz/util.pl @@ -0,0 +1,12 @@ +% == No, Emacs this is -*-Prolog-*- code, not what you thought... ============= + +% -- utility predicates ------------------------------------------------------- + +% -- subset (SUB, SET, REST) -------------------------------------------------- + +subset(L, L, []). +subset(S, [H|T], R) :- subset_aux(T, H, S, R). + + subset_aux(S, R, S, [R]). + subset_aux([H|T], R1, S, [R1|R]) :- subset_aux(T, H, S, R). + subset_aux([H|T], X, [X|S], R) :- subset_aux(T, H, S, R). -- libgit2 0.21.2