On Thu, Jun 25, 2009 at 02:47:55PM +1000, Timothy S. Nelson wrote:
> What would happen if we had an operator that returned the number of
> true values? Say we call it "boolean plus", or "bop".
...why an operator?
sub bop(*...@values) { + grep { $_ }, @values }
> To give one example: 1 bop 3 = 2
bop 1, 3
> Say we're looking at: ($x > 1) bop 3 bop ($y < 0)
bop ($x > 1), 3, ($y < 0)
> To get the boolean-logic definition, we'd do:
> ($x > 1) bop 3 bop ($y < 0) % 2
bop ($x > 1), 3, ($y < 0) % 2
> To get the natural-language one, we'd do:
> ($x > 1) bop 3 bop ($y < 0) == 1
bop ($x > 1), 3, ($y < 0) == 1
Pm