Wow, what an old thread...

Jonadab the Unsightly One writes:
> "Abhijit A. Mahabal" <[EMAIL PROTECTED]> writes:
> 
> > On the other hand, if you wanted to say "true for all except exactly
> > one value, I can't think of a way. 
>   
> Easy.  The following two statements are equivalent:
> 
> F(x) is true for all but exactly one x
> (not F(x)) is true for exactly one x
> 
> The only additional possibility that can't be phrased in terms of the
> four given is the complex generalised case:
> 
> F(x) is true for at least n but not more than m values of x

Oh, I wouldn't say that....

    use HypotheticalModules::List::Combinations 束combinations損;
    
    sub between($low, $high, [EMAIL PROTECTED]) {
        any(
            $low..$high ==> map -> $num {
                any( map { all(@$_) } combinations($num, @values) )
            }
        )
    }

Efficient?  No.  Blows out memory for (20, 30, 1..50)?  Yes.  
Works?  Yes.

We also have:

    class Betwunction is Junction {
        submethod BUILD($.low, $.high, @.values) { }
        
        method evaluate() {
            my Int $n = grep { ? $_ } @.values;
            $.low <= $n <= $.high;
        }
    }
    sub between($low, $high, @values) {
        new Betwunction: $low, $high, @values;
    }

Or something.  But I guess this one breaks the constraint of "in terms
of the four given".

> So for example you could have a list of fifty values for x and test
> whether the condition is true for at least ten but not more than
> fourty of them.  (Or, x could be the condition; you could have a list
> of fifty conditions and test whether between twenty and thirty of them
> were true.)  My guess is, however, that the frequency with which
> anyone would use such a capability would not be overwhelming.  
> 
> It would be great for obfuscation, though, particularly if some of the
> conditions had side effects with an impact on the value of the other
> conditions to be tested...  That would be sufficiently interesting
> that it's almost a shame I can't think of a real reason to request
> such a feature, since I rather doubt anyone's going to much fancy
> implementing it just for obfuscatory value ;-)

Who needs reasons?

Luke

Reply via email to