[m-dev.] For review: add '..'/2 and series/3 to list.m
Ralph Becket
rbeck at microsoft.com
Wed Sep 27 18:39:48 AEDT 2000
>From Fergus Henderson on 26/09/2000 19:22:51
> >
> > library/list.m:
> > Added '..'/2 - generates lists of ascending integers.
> > Added list__series/3 - higher order function used to
> > generate various kinds of series.
>
> The new functions should be mentioned in the NEWS file.
Done.
> > + % list__series(X, OK, Succ) = [X0, X1, ..., Xn]
> > + % where Xk = Succ^k(X) and OK(Xk) and not OK(Succ^(n+1)(X)).
> > + %
> > +:- func list__series(T, pred(T), func(T) = T) = list(T).
> > +:- mode list__series(in, pred(in) is semidet, func(in) = out is det) =
out
> > + is det.
>
> I think the documentation there is rather cryptic.
> It uses a lot of semi-formal notation which is not defined anywhere.
> It's not as understandable as an informal definition,
> and not as well-defined or precise as a genuinely formal definition.
How about this...
list__series(X, OK, Succ) = [X0, X1, ..., Xn]
where X0 = X and successive elements Xj, Xk
a computed as Xk = Succ(Xj). The series
terminates as soon as an element Xi is
generated s.t. not OK(Xi); Xi is not included
in the output.
> > + % Lo `..` Hi = [Lo, Lo + 1, ..., Hi]
> > + %
> > +:- func int `..` int = list(int).
>
> Here you should document what happens when Hi < Lo.
How about...
Lo `..` Hi = [Lo, Lo + 1, ..., Hi] if Lo =< Hi
= [] otherwise
--
Ralph Becket | MSR Cambridge | rbeck at microsoft.com
--------------------------------------------------------------------------
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