Re: ord_select ?
"Richard A. O'Keefe" <[email protected]>
| Newsgroups | gmane.comp.ai.prolog.swi |
|---|---|
| Message-ID | <[email protected]> |
On 13/02/2014, at 5:43 AM, Nicos Angelopoulos wrote:
>
> There is also the issue of whether the doc for ord_del_element/3
> should explicitly mention that the predicate does not fail in that scenario.
> The manual does say that
> This is the same as ord_subtract(Set, [Element], NewSet).
> which is certainly a warning in the right direction.
It's not just that it _happens_ not to fail,
it's that it would be WRONG for it to fail.
ord_add_element(Small, Item, Large) <->
Large = Small ∪ {Item}
The case where Item ∈ Small is well defined
mathematically so it would be WRONG to fail.
ord_del_element(Large, Item, Small) <->
Small = Large \ {Item}
The case where Item ∉ Large is well defined
mathematically so it would be WRONG to fail.
ord_selectchk(Item, Large, Small) <->
|Large| = 1+|Small| ∧
Item ∈ Large ∧
Item ∉ Small
In this case, if Item ∈ Small or Item ∉ Large
the contract would be broken and it would be
wrong NOT to fail.
> %% ord_select(+Set, +Element, -Rem).
The arguments are in the wrong order.
If ord_select/3 exists, the argument order must match
the argument order of select/3.
(You will notice that all three definitions above have
the usual inputs preceding the usual output.)
_______________________________________________
SWI-Prolog mailing list
[email protected]
https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog