[m-rev.] for review: Add take_while and drop_while to the list module
Paul Bone
paul at bone.id.au
Thu Apr 21 12:35:34 AEST 2016
On Thu, Apr 21, 2016 at 12:30:32PM +1000, Julien Fischer wrote:
>
> Hi,
>
> On Thu, 21 Apr 2016, Paul Bone wrote:
>
> >On Thu, Apr 21, 2016 at 11:55:58AM +1000, Mark Brown wrote:
> >>Hi Paul,
> >>
> >>On Thu, Apr 21, 2016 at 11:11 AM, Paul Bone <paul at bone.id.au> wrote:
> >>> For review by anyone
> >>>
> >>> ---
> >>>
> >>> Add take_while and drop_while to the list module
> >>
> >>Are you aware there is already a takewhile predicate in the list module?
> >>
> >
> >No I wasn't, it looks like it behaves differently anyway.
>
> It also returns the leading elements for which Pred succeeds. It's not
> too different from us having multiple versions of list.filter (i.e. one
> version that returns just the true list and one that returns the true
> and false lists).
>
> >I noticed that in our YesLogic code we have some utility code that can be
> >put into the Mercury standard library, including a dropwhile predicate. So
> >I named it drop_while and submitted it and an similar take_while predicate.
> >
> >I don't really mind what happens, does anyone else have any strong ideas
> >about these kinds of predicates?
>
> I would prefer some consistency in naming for a start ;-)
>
> I suggest adding take_while/4, deprecating the existing takewhile/4
> predicate and adding your new ones as well. (That said, I think the
> documentation for drop_while/3 is unclear, so don't commit them
> until that's been reviewed.)
To clarify, we would be (in the long term) renaming takewhile/4 to
take_while/4?
Cheers.
--
Paul Bone
More information about the reviews
mailing list