Changeset 4216 for trunk/library/set1.lgt
- Timestamp:
- 04/22/08 08:09:59 (4 months ago)
- Files:
-
- 1 modified
-
trunk/library/set1.lgt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/library/set1.lgt
r2737 r4216 4 4 5 5 :- info([ 6 version is 1. 01,6 version is 1.1, 7 7 author is 'Paulo Moura', 8 date is 200 6/4/25,8 date is 2008/4/22, 9 9 comment is 'Set predicates with elements constrained to a single type.']). 10 10 11 valid(Set) :- 12 nonvar(Set), 11 valid(-) :- % catch variables 12 !, 13 fail. 14 valid([]) :- 15 !. 16 valid([Element| Set]) :- 17 check_order(Set, Element). 18 19 check_order(-, _) :- % catch unbound tails 20 !, 21 fail. 22 check_order([], _) :- 23 !. 24 check_order([Element2| Set], Element1) :- 13 25 parameter(1, Type), 14 \+ \+ valid(Set, Type).15 16 valid([], _) :-17 !.18 valid([Element], Type) :-19 !,20 Type::valid(Element).21 valid([Element1, Element2| Set], Type) :-22 Element1 @< Element2,23 26 Type::valid(Element1), 24 27 Type::valid(Element2), 25 valid([Element2| Set], Type). 28 Element2 @> Element1, 29 check_order(Set, Element2). 26 30 27 31 :- end_object.
