[m-dev.] For review: minor additions to list.m and string.m
Ralph Becket
rbeck at microsoft.com
Fri Sep 8 19:13:26 AEDT 2000
> But maybe something like
>
> :- func series(T, pred(T) is semidet, func(T) = T) = list(T).
>
> series(Init, Test, Inc) =
> ( Test(Init) ->
> [Init | series(Inc(Init), Test, Inc)]
> ; []
> ).
>
> would be general enough to be useful often enough to bother with?
> (This is completely untested; I hope it's close enough to correct that
> you know what I mean.) Then if you want a geometric series you can
> always write something like series(1, >(1000), *(2)).
>
> Kind of looks a bit like a C for loop, doesn't it?
Modulo typesetting and names, this is identical to the code I came up
with, which seems to work fine.
By the way, a while back I suggested that, just as a function without
a mode declaration is assigned a `func(in, in, ..., in) = out is det'
mode by default, a predicate without a mode declaration should have a
default mode of `pred(in, in, ..., in) is semidet'. But I don't think
I got a response.
This crops up so often that I'd really like to see it included. One
can always get mode inference using a compiler switch (or pragma?)
Ralph
--------------------------------------------------------------------------
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