[racket-dev] Mangaging `unstable` with packages

From: Eli Barzilay (eli at barzilay.org)
Date: Mon Jun 24 07:37:29 EDT 2013

A few minutes ago, Sam Tobin-Hochstadt wrote:
> On Mon, Jun 24, 2013 at 3:52 AM, Eli Barzilay <eli at barzilay.org> wrote:
> > On Friday, Sam Tobin-Hochstadt wrote:
> >>
> >> # `unstable/list`
> >>
> >> - `remf`, `list-update` `list-set` `map/values`: move to
> >>   `racket/list`
> >> - `group-by`: rename to `group`, add keyword argument `#:by`
> >> defaulting to `equal?`, move to `racket/list`
> >
> > All of these are used in the tree only by their authors, and almost
> > all of them are used between zero and time.
> >
> > `remf' is the same as `filter-not'.
> 
> This is false, as the example in the `remf` docs shows.

s/same/almost the \1/

[We already went over this: I don't find the remove-first
functionality too useful (I use (remove* (list x) l) *very*
frequently), but with a function a `remf' that is not a `refm*' is
even less useful and more surprising.]

> > `map/values' can be expressed in most cases more conveniently with
> > `for/fold'.
> 
> I've used `map/values`, and I'm not its author. Also, it's a
> function that I've seen requested for years.

(OK, "sam added from carl"; but you're still the only client in the
tree.)


> > `group-by' is doing something weird -- see for example clojure's
> > function by the same name that does something that looks more
> > useful (IMO).  Also, `group' sounds way too generic for something
> > as specific as what it does.
> 
> `group-by`, and my proposed `group`, is what Haskell provides.  I
> don't find the Clojure version nearly as compelling, since it
> combines a map and a grouping operation.

Haskell does something more tame, and more predictable in the sense of
splitting an ordered list.  And yes, it looks like a good idea to have
*that*.

To be clear, the list-splitting functionality that I'd like to have:

* Split a list to lists of length N (IIRC, clojure has some
  generalization where you specify an interval length + chunk length,
  so if you use 1,2 you get something like (x y z) => ((x y) (y z)).)

* Split the list by some predicate over the elements, common use: take
  a list of strings and split it over "\n" items.  Clojure has
  `partition-by' which is close, and the Haskell group-by can probably
  be used too (but possibly not conveniently enough to eliminate the
  need for what I want).

(And as a sidenote, I agree with you that the clojure `group-by' is
not too useful -- I think that this applies to many list functions
that pretend that their input is a set.)

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!

Posted on the dev mailing list.