ref: 95f874fe29b84394748d660a536a516277184288
parent: 03738c67684b83692d9112858f07c745f355a157
author: Peter Mikkelsen <peter@pmikkelsen.com>
date: Tue Jul 6 17:54:59 EDT 2021
Add list module
--- /dev/null
+++ b/lists.pl
@@ -1,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).