This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
yap-6.3/Logtalk/library/set1.lgt

28 lines
516 B
Plaintext
Raw Normal View History

:- object(set(_type),
extends(set)).
:- info([
version is 1.0,
author is 'Paulo Moura',
date is 2006/2/2,
comment is 'Set predicates with elements constrained to a single type.']).
valid(Set) :-
nonvar(Set),
parameter(1, Type),
\+ \+ valid(Set, Type).
valid([], _) :-
!.
valid([Element], Type) :-
!,
Type::valid(Element).
valid([Element1, Element2| Set], Type) :-
Element1 @< Element2,
Type::valid(Element1),
Type::valid(Element2),
valid([Element2| Set], Type).
:- end_object.