[m-rev.] for review: improve stack usage of list.series/3 and `..`

Julien Fischer juliensf at cs.mu.OZ.AU
Mon Apr 4 14:19:11 AEST 2005


On Mon, 4 Apr 2005, Ralph Becket wrote:

> Julien Fischer, Monday,  4 April 2005:
> >
> > Index: library/list.m
> > ===================================================================
> > RCS file: /home/mercury1/repository/mercury/library/list.m,v
> > retrieving revision 1.136
> > diff -u -r1.136 list.m
> > --- library/list.m	1 Apr 2005 14:29:19 -0000	1.136
> > +++ library/list.m	4 Apr 2005 01:04:37 -0000
> > @@ -1990,17 +1990,36 @@
> >
> >  %-----------------------------------------------------------------------------%
> >
> > -list__series(I, OK, Succ) =
> > +list__series(I, OK, Succ) = Series :-
> > +	list__series_2(I, OK, Succ, [], Series0),
> > +	list__reverse(Series0, Series).
> > +
> > +:- pred list__series_2(T, pred(T), func(T) = T, list(T), list(T)).
> > +:- mode list__series_2(in, pred(in) is semidet, func(in) = out is det,
> > +	in, out) is det.
> > +
> > +list__series_2(I, OK, Succ, !Series) :-
> >  	( OK(I) ->
> > -		[I | list__series(Succ(I), OK, Succ)]
> > +		!:Series = [ I | !.Series ],
> > +		list__series_2(Succ(I), OK, Succ, !Series)
>
> In this case, I don't think state variables make this more legible.
>
Ok.  I've removed them here and below.

Julien.
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list