[prev in list] [next in list] [prev in thread] [next in thread]
List: perl6-language
Subject: Re: XOR does not work that way.
From: "Patrick R. Michaud" <pmichaud () pobox ! com>
Date: 2009-06-25 5:58:20
Message-ID: 20090625055820.GA7194 () pmichaud ! com
[Download RAW message or body]
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
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic