|
Revision 4216, 0.6 KB
(checked in by pmoura, 7 months ago)
|
|
Updated the definitions of the predicate valid/1 for the library objects "list", "list(Type)", "numberlist", "set", "set(Type)", "varlist" to fail for lists with unbound tails after discussion with Jan Wielemaker and Ulrich Neumerkel.
|
-
Property svn:eol-style set to
native
-
Property svn:keywords set to
Author Date Id Revision
|
| Line | |
|---|
| 1 | |
|---|
| 2 | :- object(set(_Type), |
|---|
| 3 | extends(set)). |
|---|
| 4 | |
|---|
| 5 | :- info([ |
|---|
| 6 | version is 1.1, |
|---|
| 7 | author is 'Paulo Moura', |
|---|
| 8 | date is 2008/4/22, |
|---|
| 9 | comment is 'Set predicates with elements constrained to a single type.']). |
|---|
| 10 | |
|---|
| 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) :- |
|---|
| 25 | parameter(1, Type), |
|---|
| 26 | Type::valid(Element1), |
|---|
| 27 | Type::valid(Element2), |
|---|
| 28 | Element2 @> Element1, |
|---|
| 29 | check_order(Set, Element2). |
|---|
| 30 | |
|---|
| 31 | :- end_object. |
|---|