[m-dev.] For review: minor additions to list.m and string.m
Ralph Becket
rbeck at microsoft.com
Fri Sep 8 18:28:12 AEDT 2000
> > > library/list.m:
> > > Added func ++/2 as a synonym for list__append/2.
> > > Added func '..'/1 to generate ascending/descending integer range
> > > lists.
> >
> > Firstly, s/1/2/.
Done.
> > I'm not sure this is the best way to do descending
> sequences. This means
> > you can never generate an empty list. Eg, I would find
> >
> > 1..0 = []
> >
> > more natural than
> >
> > 1..0 = [1,0]
>
> I agree. Also the behaviour of `..' is inconsistent with Haskell,
> for which `[1..0]' evaluates to `[]'. In Haskell, you need to write
> `[1,0..0]' to get `[1,0].
I, too, agree. I just remember the last time someone suggested this
they wanted the behaviour I implemented and there were no howls from
the gallery.
How about this: `..`/2 is the inclusive ascending series
(N `..` M) = Seq
<=> all [I] (index0(Seq, I, X) => (X = N + I, X =< M))
and add
arith_series(N, M, D) = Seq
<=> ( if D > 0 then
all [I] (index0(Seq, I, X) => (X = N + I * D, X =<
M))
else if D < 0 then
all [I] (index0(Seq, I, X) => (X = N + I * D, X >=
M))
else /* D = 0 */
throw(a_wobbly)
)
> Ralph, the `++' methods look fine; unless there are any other
> objections, I suggest you go ahead and commit those.
>
> For `..', I suggest you change the semantics to match those
> in Haskell.
I think arith_series/3 captures that.
Any takers for geom_series/3? Or is that of too little use? Mind you, it
would be trivial to include.
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