Patrick R. Michaud wrote:
Rod Adams wrote:
I would argue that this sort of relational comparison is of limited usefulness.
Well, except junctions hold more information than the simple comparisons I've given here. For example, a junction can have a value like:
$x = ($a & $b) ^ ($c & $d)
which is true only if $a and $b are true or $c and $d are true but not
both.
That's why I allowed for virtual sets, defined by a closure.
Of course we'll always have C<grep>. But this is Perl, and I want YAWTDI.Invariably, the next question that will nearly always be asked is "_Which_ values worked / didn't work?".
If you're wanting to know *which* values worked, we still have C<grep> --
we don't need a special set notation for it, or to worry about junctions.
After all, another way to test membership was just added, whereas before you pretty much just had C<grep>.
and((2,3,4) ?<= 3)
btw, I like and()/or() over all()/any() because it makes it very clear we are establishing a boolean context.
To me the fact that we're using <= establishes that we're interested
in a boolean result; I don't need "and/or" to indicate that. Using
"and" to mean "all" doesn't quite work for me, as I somehow think of
"and" as a two-argument operation.
That's a minor quibble, and I could go either way.
I saw a reference to a flavor of Pascal that used it that way. C<x> might be more in line with the math notation for it, but somehow I doubt that would make you feel better.[intersection] #foo * #bar # and we even know which ones!
[containment] #foo <= #bar
[non-intersection]
!(#foo * #bar)
Somehow overloading C<*> to mean "intersection" just doesn't work for
me here. I'd have to think about it.
My issue is less that lists and sets are radically different. It is much more a matter of Junctions and Scalars are radically different. Getting me to accept that a Scalar holds several different values at once is a hard sell. Especially when you consider duplicated side effects.Ultimately I don't think I agree with the notion that sets and lists are so different, or that sets deserve/require their own sigil.
And what happens if you attempt to evaluate a junction in a non-boolean context?
-- Rod Adams