If we have 3 input sets, then the '110' selector string selects all elements that are in the first and second sets but not in the third.

This looks like an INNER JOIN operation as known from SQL. But there's no facility to select elements that are unique to each set, i.e. select elements from each set which aren't present in the other sets (which would be an OUTER JOIN, right?).

So, the selector string should sport the values (012) or it should not be a string rather than an arrayref holding -1,0,1 elements. That would be more perlish (e.g.sort). I haven't thought of all combinations of intersecting three or more sets, which would require more than just three values for each set, or of a language to combine possible intersections of 3 or more sets; but I think that a good name would be Set::Intersect.

Then, thinking a bit more - if you want the string interface, then a lispish sort of query specification might do the job, as used in LDAP queries - (|(&(1=0)(!(2=-1)))(3=1)(4=1)) - perhaps translated into "and", "or", "in", "not in" and such to make it more perlish. Or "and", "or", "not", "nor", "xor" etc - basically, you need boolean logic and precedence to process things, and a descriptive input specification which supports that.

perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'

In reply to Re: RFC: Set::Select: get intersection or union of sets; or more generally, the set of elements that are in one or more input sets by shmem
in thread RFC: Set::Select: get intersection or union of sets; or more generally, the set of elements that are in one or more input sets by kikuchiyo

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.