[m-dev.] for review: use bitsets in quantification
Fergus Henderson
fjh at cs.mu.OZ.AU
Wed Nov 8 04:33:40 AEDT 2000
On 07-Nov-2000, Ralph Becket <rbeck at microsoft.com> wrote:
> > > So we include (at least) to_int/1, from_int/1, first/0, last/0.
> > > I think pred/1 and succ/1 should also go in there as methods
> > > rather than utility functions since they may be more economically
> > > implemented than
> > > pred(X) = from_int(to_int(X) - 1)
> > > succ(X) = from_int(to_int(X) + 1)
> >
> > Could you give an example of a more economic implementation?
>
> This is a bit contrived, but the set of strings is enumerable and
> I expect it would be more efficient to work directly on the string
> representation than to convert back and forth between int(eger)s.
>
> Now you put the question, I'm having trouble thinking of a
> non-contrived example...
BTW, these two should probably be named `prev' and `next'
rather than `pred' and `succ', to avoid confusion with the use of
`pred' for "predicate" in lambda expressions and pred declarations.
I guess even in the ordinary case, defining these as methods does mean
you need only pay one virtual call rather than two virtual calls to
get each element. Perhaps that is enough to justify it.
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
| of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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