-
Notifications
You must be signed in to change notification settings - Fork 0
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
Use a pair instead of a list to represent intervals #9
Comments
Thanks Paulo. This is a nice suggestion actually. I might be needing some ways to get the first or the second element of the pair in the future. I know how to do this with lists, but I'm not sure how this could be possible with pairs. I'll look it up. As the |
I found this suggestion regarding my question above. |
Not sure I understand the problem. You can simply use unification as you're doing with lists. E.g. is_in((Xa, Xb), Number) :-
Xa =< Number,
Xb >= Number. |
I wasn't thinking about the predicates from But it seems that unification should be enough. I'll have to think things harder, it seems. Thanks ! |
The So far all the created tests pass with 100%. For this reason I'll close this issue. |
Representing an interval using a pair, e.g.
(X,Y)
is more efficient than using a list,[X,Y]
. To make it clear:I.e. accessing the upper limit in an interval is more costly with a list representation.
The text was updated successfully, but these errors were encountered: