ok, I'll check that stuff out.  Thanks.

It occurs to me this is being compared to something in ruby called
partition.  I like that name.  "partition-by" ... but maybe it was opted to
use the simpler name, which I can appreciate.

On that subject, I know "filter" is standard from other languages like
Haskell, but I had to learn that it meant "retain-if".  To me, "filter"
sounds synonymous with "remove".  Other candidates: "keep", "preserve".
Also, that "-by" convention sounds right for partition or separate, but in
the case of filter and remove, "if" sounds better.  I suggest breaking from
the "filter" tradition and going with "retain-if" and "remove-if".

On Sun, Jan 25, 2009 at 6:10 PM, Stephen C. Gilardi <squee...@mac.com>wrote:

>
> On Jan 25, 2009, at 5:24 PM, e wrote:
>
>  Do folks in the contrib group like this new implementation?
>>
>
> To make contributions to clojure-contrib, you'll need to have a Contributor
> Agreement on file with Rich. Please see http://clojure.org/contributing .
>
> I think your implementation is an improvement over the current
> clojure.contrib.seq-utils/separate.
>
> I have some suggestions:
>
>        - there's precedent for functions that do one thing or another based
> on a predicate to be named with a "-by" suffix.
>        - using vectors for the intermediate results will allow the
> separated outputs to preserve the order of the input which might be helpful
> to some callers. Since it will still give good performance, I'd opt for that
> and promise it in the doc string.
>        - you might also consider using the names first and rest for the
> destructured names you called f and r. I would imagine that's a bit
> controversial (because the local names would shadow useful functions), but
> arguably it would make the implementation easier to read.
>        - returning a vector of vectors seems good to me.
>
> Here's an implementation:
>
> user>  (defn separate-by [pred coll]
>         (loop [in [] out [] [f & r] coll]
>           (if f
>             (if (pred f)
>               (recur (conj in f) out r)
>               (recur in (conj out f) r))
>             [in out])))
>
> #'user/separate-by
> user> (separate-by odd? [1 2 3 4 5 6 7])
> [[1 3 5 7] [2 4 6]]
> user>
>
> Whatever you propose will need a doc string.
>
> After Rich receives your Contributor Agreement and your name is up on the
> clojure.org/contributing page, please enter an issue against
> clojure-contrib noting that your alternate implementation for the current
> clojure.contrib.seq-utils/separate has higher performance while still being
> maintainable and correct. Include a complete copy of the code you propose,
> preferably as a patch.
>
> Once the issue is up, I'd follow up in this thread with the issue number
> requesting that Stuart consider resolving the issue by adopting your
> contribution.
>
> --Steve
>
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to