I wrote a simple program to play with the mundane use of this predicate: someio :- between(2,5,X), write(X), nl, fail.
But I dont understand the practical use of making the second argument infinite: between(X,infinite,Y)
And I also dont understand what the docs are saying exactly: """If High is inf or infinite, between/3 is true iff Value >=Low, a feature that is particularly interesting for generating integers from a certain value."""
>I wrote a simple program to play with the mundane use of this >predicate: >someio :- between(2,5,X), write(X), nl, fail.
>But I dont understand the practical use of making the second argument >infinite: >between(X,infinite,Y)
>And I also dont understand what the docs are saying exactly: >"""If High is inf or infinite, between/3 is true iff Value >=Low, a >feature that is particularly interesting for generating integers from >a certain value."""
Many implementations of between/3 do not have this feature. For this reason I write length(_, N). This is very useful in situations where you are searching for counterexamples.
Concerning between/3, it is not clear whether or not the name infinite or inf is ideal, since in clpfd implementations inf refers to the infimum. I.e.,
> I wrote a simple program to play with the mundane use of this > predicate: > someio :- between(2,5,X), write(X), nl, fail.
> But I dont understand the practical use of making the second argument > infinite: > between(X,infinite,Y)
> And I also dont understand what the docs are saying exactly: > """If High is inf or infinite, between/3 is true iff Value >=Low, a > feature that is particularly interesting for generating integers from > a certain value."""
Typically, you need this if you want to generate increasing integers until some condition is met and you have no clue when that will be. So, you write
Using infinite is a bit more informative than writing this, even if you know that 1 million is plenty. Of course, the downside is that the above is a nearly infinite loop if is_this_want_i_want/1 never succeeds (nearly, because memory is finite and the increasing N will keep using more :-)