-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Assert domain from set of values #13
Comments
Thank you, this is certainly worth considering! Do you have any concrete use case in mind? In my experience, this need arises quite rarely. Maybe it would be even more useful to add a predicate like |
I have not played around enough with Prolog and clpfd/z to have a concrete use case right now but from the top of my head, from dealing with other languages, discrete domains happen all the time, like HTTP status code for example, that's why they usually have the Enum type with custom values. Agree with the |
OK! Please let's leave this issue open for now, and implement it when there is a clear need for it. One reason why I do not immediately add it is that every new primitive for reasoning about domains will reduce compatibility with other constraint systems. Another reason is that beginners tend to quickly adopt bad patterns if too many primitives are available. For example, we will quickly see: list_domain([400,402,404], Dom), X in Dom which can already now be written more compactly and also more portably as: X in 400\/402\/404 Would this solve your issue with HTTP status codes? Also, we will likely even see: list_domain([1,2,3], Dom), X in Dom which can be written as: X in 1..3 I have seen this occur repeatedly in the past. For instance, Therefore, if at all possible, I would like to keep the provided features as simple and as portable as possible. I'm certainly sympathetic to adding |
That's reasonable. At list this issue can serve as a pointer to anyone having the same problem. |
I see from your knight's tour example , you wrote a small utility to convert a list of values to a domain:
where:
I think this should be part of the library itself. Something like:
The text was updated successfully, but these errors were encountered: