shithub: pprolog

Download patch

ref: 1ca3670047172610f0c284df5d5171fa840f97ce
parent: d5ac41480097d6f382fbb2385974e57ec21030a4
author: Peter Mikkelsen <peter@pmikkelsen.com>
date: Wed Jun 30 19:53:19 EDT 2021

Add length/2 and member/2

--- a/example.pl
+++ b/example.pl
@@ -24,6 +24,3 @@
 
 =(A,A).
 
-length([], zero).
-length([Head|Tail], suc(Length)) :-
-	length(Tail, Length).
--- a/stdlib.pl
+++ b/stdlib.pl
@@ -55,3 +55,14 @@
 	A == B.
 A @>= B :-
 	A @> B.
+
+% List predicates
+
+length([], 0).
+length([_|Tail], Length) :-
+	length(Tail, Length0),
+	Length is Length + 1.
+
+member(X, [X|_]).
+member(X, [_|Tail]) :-
+	member(X, Tail).