diff options
-rw-r--r-- | example.pl | 3 | ||||
-rw-r--r-- | stdlib.pl | 11 |
2 files changed, 11 insertions, 3 deletions
@@ -24,6 +24,3 @@ tester(A, B) :- true. =(A,A). -length([], zero). -length([Head|Tail], suc(Length)) :- - length(Tail, Length). @@ -55,3 +55,14 @@ A @>= B :- 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). |