[m-rev.] for review add ranges.search_member/4

Zoltan Somogyi zoltan.somogyi at runbox.com
Sat Mar 16 17:14:33 AEDT 2024


On 2024-03-16 17:08 +11:00 AEDT, "Julien Fischer" <jfischer at opturion.com> wrote:
> The main thing I would like is feedback on is the name of the new
> prediate.

I don't particularly like it, but can't think of anything better.

> (Also, the test suite does not currently appear to contain
> any specific tests of the ranges module; I intend to extend the test
> case included in this diff to cover the rest of the ranges module in a
> separate change.)

Good idea.

> +    % search_member(N, Set, L, H):
> +    % L and H are the endpoints of the range in Set that contains N.

I would reword as

If N is in Set, then succeed, setting Lo and Hi to the endpoints
of the range in which it is contained.

> +search_member(N, range(L0, H0, Rest), L, H) :-
> +    ( if
> +        N > L0,
> +        N =< H0
> +    then
> +        L = L0 + 1,
> +        H = H0
> +    else
> +        search_member(N, Rest, L, H)
> +    ).

I would s/L/Lo/ and s/H/Hi/ here as well.

The rest of the diff is fine.

Zoltan.


More information about the reviews mailing list