Changeset 4216 for trunk/library/set.lgt
- Timestamp:
- 04/22/08 08:09:59 (5 months ago)
- Files:
-
- 1 modified
-
trunk/library/set.lgt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/library/set.lgt
r4191 r4216 5 5 6 6 :- info([ 7 version is 1. 0,7 version is 1.1, 8 8 author is 'Paulo Moura', 9 date is 200 0/7/24,9 date is 2008/4/22, 10 10 comment is 'Set predicates implemented using ordered lists. Uses ==/2 for element comparison and standard term ordering.']). 11 11 … … 179 179 union([Head1| Tail1], Tail2, Union). 180 180 181 valid(Set) :- 182 nonvar(Set), 183 valid2(Set). 181 valid(-) :- % catch variables 182 !, 183 fail. 184 valid([]) :- 185 !. 186 valid([Element| Set]) :- 187 check_order(Set, Element). 184 188 185 valid2([]) :- 189 check_order(-, _) :- % catch unbound tails 190 !, 191 fail. 192 check_order([], _) :- 186 193 !. 187 valid2([_]) :- 188 !. 189 valid2([Element1, Element2| Set]) :- 190 Element1 @< Element2, 191 valid2([Element2| Set]). 194 check_order([Element2| Set], Element1) :- 195 Element2 @> Element1, 196 check_order(Set, Element2). 192 197 193 198 :- end_object.
