[m-dev.] for review: add `do_while/4' to std_util.m
Tyson Dowd
trd at cs.mu.OZ.AU
Tue Oct 19 17:12:53 AEST 1999
On 19-Oct-1999, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> Estimated hours taken: 2
>
> library/std_util.m:
> Implement `do_while/4'.
>
> samples/README:
> samples/all_solutions.m:
> samples/committed_choice.m:
> samples/solutions/all_solutions.m:
> samples/solutions/one_solution.m:
> samples/solutions/some_solutions.m:
> Move the all_solutions.m and committed_choice.m samples
> into a new subdirectory `solutions', renaming committed_choice.m
> as `one_solution.m', and add a new file `some_solutions.m'
> illustrating the use of `do_while/4'.
> (Also fix some documentation rot in samples/README.)
>
> NEWS:
> Mention the new predicate std_util__do_while/4.
>
Just one comment.
> @@ -182,6 +182,37 @@
> :- mode unsorted_aggregate(pred(muo) is nondet, pred(mdi, di, uo) is det,
> di, uo) is cc_multi.
>
> + % This is a generalization of unsorted_aggregate which allows the
> + % iteration to stop before all solutions have been found.
> + % Declaratively, the specification is as follows:
> + %
> + % do_while(Generator, Filter) -->
> + % { solutions(Generator, Solutions) },
> + % do_while_2(Solutions, Filter).
> + %
> + % do_while_2([], _) --> [].
> + % do_while_2([X|Xs], Filter) :-
> + % Filter(X, More),
> + % (if { More = yes } then
> + % do_while_2(Xs, Filter)
> + % else
> + % { true }
> + % ).
I was about to write complaining that I don't think declarative
semantics should be defined using DCG notation (because it looks a
little sloppy and confusing) but then I realized that
you have a bug in your specification anyway because of the use of :-
instead of -->.
So I think at least fix the bug, and maybe remove the DCG notation.
Apart from that the change is fine.
--
Tyson Dowd #
# Surreal humour isn't eveyone's cup of fur.
trd at cs.mu.oz.au #
http://www.cs.mu.oz.au/~trd #
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to: mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions: mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------
More information about the developers
mailing list