lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On Wed, Nov 17, 2010 at 09:40, Kristofer Karlsson
<> wrote:
> Something like this seems to satisfy most if not all of those requirements.
> local MT = {}
> FALSE = setmetatable({-1, "FALSE"}, MT)
> NA = setmetatable({0, "NA"}, MT)
> TRUE = setmetatable({1, "TRUE"}, MT)

Actually it should be
FALSE = setmetatable({1, "FALSE"}, MT)
NA = setmetatable({0, "NA"}, MT)
TRUE = setmetatable({-1, "TRUE"}, MT)

In order to map XOR into regular multiplication FALSE is 1 and TRUE is -1.
This is counterintuitive but has been used with great success in DSPs and ASICs.