develooper Front page | perl.perl6.language | Postings from March 2009

Re: decision operator

Thread Previous | Thread Next
From:
Moritz Lenz
Date:
March 24, 2009 16:26
Subject:
Re: decision operator
Message ID:
49C96C07.3010504@faui2k3.org
Ruud H.G. van Tol wrote:
> I wonder if there is place for a "decision operator".
> (search terms: FPGA, evolvable hardware, Xilinx, PLB, LUT, NESW)
> 
> 
> dop:| 0 1 2 3 4 5 6 7 8 9 A B C D E F
> ----+--------------------------------
> 0 0 | 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1
> 0 1 | 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1
> 1 0 | 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1
> 1 1 | 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
> 
> 
> So for two boolean inputs,
> "&" is an alias of dop(1),
> "|" is an alias of dop(0x07),
> "^" is an alias of dop(0b0110).
> 
> (1,0).dop(7) returns 1 because (1 | 0) == 1
> 
> (4,3).dop(7) returns 7 because (4 | 3) == 7
> 
> ("A","F").dop(7) returns "G" because ("A" | "F") eq "G"
> 
> (1,1,1).dop(0b01101001) returns 1 because (1^1^1) == 1

This looks like a perfect place for a (possibly user defined) operator
with an attribute, something like

1 ~~ 0 :dop(7)

Cheers,
Moritz


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About