An idea as to naming inspiration:

Ruby has similar methods on Array called select! and reject! which are in place versions of select and reject. The latter pair work similar to Perl's grep (returning elements for which the block provided returns true (or for which it doesn't return true for reject)), whereas the bang-suffixed versions follow Ruby convention and diddle their argument in place to remove the affected elements.

(And for the curious, Ruby does have a a.grep( pattern ) method on the array but it works using the === comparison operator to check pattern === element rather than using a predicate block; if it's given a block it behaves like a map on the matching items. There is no grep! though, which is kinda strange seeing that the other filtering methods have mutators.)

Update: Oh wait, you're returning the removed elements as well. select! and reject! just return the newly changed array, or nil if no modifications were made. Duuur. Me not awake yet.

Never mind, this is actually more like partition (which takes a block and returns two arrays, one for elements for which the block returned true and the other for elements for which it returned false), but there's not a mutator variant of that.


In reply to Re: RFC: List::Extract by Fletch
in thread RFC: List::Extract by lodin

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.