shithub: pprolog

ref: 2c166a1496c5638924d29df9dcf6c125a31ce18c
dir: pprolog/stdlib.pl

View raw version
% Logic and control predicates
\+ Goal :- call(Goal), !, fail.
\+ Goal.

once(Goal) :-
	call(Goal),
	!.

repeat :- true ; repeat.

% Control structures. 
true.

If -> Then :-
	If, !, Then.

If -> Then ; _ :- 
	If, !, Then.

_ -> _ ; Else :-
	!, Else.

If ; _ :-
	If.

_ ; Else :-
	Else.

% Term unification
A = A.

A \= B :- 
	\+ A = B.

% Comparison of terms using the standard order

A == B :-
	compare(=, A, B).

A \== B :-
	\+ A == B.

A @< B :-
	compare(<, A, B).

A @=< B :-
	A == B.
A @=< B :-
	A @< B.

A @> B :-
	compare(>, A, B).

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).