summaryrefslogtreecommitdiff
path: root/misc.prolog
diff options
context:
space:
mode:
authorJed Barber <jjbarber@y7mail.com>2014-04-03 21:07:06 +1100
committerJed Barber <jjbarber@y7mail.com>2014-04-03 21:07:06 +1100
commit0b65dd864a804a6b96ca1b8aeacd947eeb361538 (patch)
tree288974d3d6f9b9ddf6d1cd7f03c0a8215f4069e4 /misc.prolog
parent133d71983ea4e39e6e971ca052b2eb0bf7437cc6 (diff)
Moving some clauses around to more appropriate modules
Diffstat (limited to 'misc.prolog')
-rw-r--r--misc.prolog20
1 files changed, 20 insertions, 0 deletions
diff --git a/misc.prolog b/misc.prolog
new file mode 100644
index 0000000..6d8ad68
--- /dev/null
+++ b/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.
+