[m-dev.] for review: switches via binary search
Fergus Henderson
fjh at cs.mu.oz.au
Wed Dec 31 04:19:56 AEDT 1997
On 30-Dec-1997, Zoltan Somogyi <zs at cs.mu.oz.au> wrote:
>
> +:- pred tag_switch__divide_ptag_range(ptag_case_list, tag_bits,
> + ptag_case_list, ptag_case_list).
> +:- mode tag_switch__divide_ptag_range(in, in, out, out) is det.
> +
> +tag_switch__divide_ptag_range([], _LowRangeEnd, [], []).
> +tag_switch__divide_ptag_range([PtagGroup | PtagGroups], LowRangeEnd,
> + LowRange, HighRange) :-
> + PtagGroup = Ptag - _,
> + ( Ptag > LowRangeEnd ->
> + tag_switch__divide_ptag_range(PtagGroups, LowRangeEnd,
> + LowRange, HighRange0),
> + HighRange = [PtagGroup | HighRange0]
> + ;
> + tag_switch__divide_ptag_range(PtagGroups, LowRangeEnd,
> + LowRange0, HighRange),
> + LowRange = [PtagGroup | LowRange0]
> + ).
It might be more elegant to implement this using list__filter/4.
> +:- pred tag_switch__divide_stag_range(stag_goal_list, int,
> + stag_goal_list, stag_goal_list).
> +:- mode tag_switch__divide_stag_range(in, in, out, out) is det.
> +
> +tag_switch__divide_stag_range([], _LowRangeEnd, [], []).
> +tag_switch__divide_stag_range([PtagGroup | PtagGroups], LowRangeEnd,
> + LowRange, HighRange) :-
> + PtagGroup = Ptag - _,
> + ( Ptag > LowRangeEnd ->
> + tag_switch__divide_stag_range(PtagGroups, LowRangeEnd,
> + LowRange, HighRange0),
> + HighRange = [PtagGroup | HighRange0]
> + ;
> + tag_switch__divide_stag_range(PtagGroups, LowRangeEnd,
> + LowRange0, HighRange),
> + LowRange = [PtagGroup | LowRange0]
> ).
Ditto. Hang on, how does this differ from the previous one?
The fact that the variables are named Ptag* strongly suggests
a possible cut-and-paste error.
> +:- pred tag_switch__divide_ptag_range(ptag_case_list, tag_bits,
> + ptag_case_list, ptag_case_list).
> +:- mode tag_switch__divide_ptag_range(in, in, out, out) is det.
> +
> +tag_switch__divide_ptag_range([], _LowRangeEnd, [], []).
> +tag_switch__divide_ptag_range([PtagGroup | PtagGroups], LowRangeEnd,
> + LowRange, HighRange) :-
Hmm, didn't I see that already?
> +:- pred tag_switch__divide_stag_range(stag_goal_list, int,
> + stag_goal_list, stag_goal_list).
> +:- mode tag_switch__divide_stag_range(in, in, out, out) is det.
> +
> +tag_switch__divide_stag_range([], _LowRangeEnd, [], []).
> +tag_switch__divide_stag_range([PtagGroup | PtagGroups], LowRangeEnd,
> + LowRange, HighRange) :-
I'm getting serious deja vu here ;-)
I'm not sure why these are included twice in the diff.
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh> | of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3 | -- the last words of T. S. Garp.
More information about the developers
mailing list