summaryrefslogtreecommitdiff
path: root/lists.pl
diff options
context:
space:
mode:
Diffstat (limited to 'lists.pl')
-rw-r--r--lists.pl16
1 files changed, 16 insertions, 0 deletions
diff --git a/lists.pl b/lists.pl
new file mode 100644
index 0000000..ee75110
--- /dev/null
+++ b/lists.pl
@@ -0,0 +1,16 @@
+:- module(lists, []).
+
+% List predicates
+
+length([], 0).
+length([_|Tail], Length) :-
+ length(Tail, Length0),
+ Length is Length0 + 1.
+
+member(X, [X|_]).
+member(X, [_|Tail]) :-
+ member(X, Tail).
+
+append([], Ys, Ys).
+append([X|Xs], Ys, [X|Rest]) :-
+ append(Xs, Ys, Rest).