From 19e66dbd8fd3bd66f286bbbcd7ce842d727a4422 Mon Sep 17 00:00:00 2001 From: Jed Barber Date: Fri, 4 Apr 2014 01:48:43 +1100 Subject: Makefile added, files reorganised --- src/misc.prolog | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/misc.prolog (limited to 'src/misc.prolog') diff --git a/src/misc.prolog b/src/misc.prolog new file mode 100644 index 0000000..6d8ad68 --- /dev/null +++ b/src/misc.prolog @@ -0,0 +1,20 @@ + +:- module(misc, [filter/3, head/2, tail/2]). + + + + +filter(List, Predicate, Result) :- + Test =.. [Predicate,X], + findall(X, Test, No), + subtract(List, No, Result). + + +head(X,[Y]) :- X = Y. +head(X,[Y|_]) :- X = Y. + + +tail(X,[]) :- X = []. +tail(X,[_]) :- X = []. +tail(X,[_|Y]) :- X = Y. + -- cgit