lua-users home
lua-l archive

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


On Wed, Nov 17, 2010 at 01:31, Alexander Gladysh <agladysh@gmail.com> wrote:
> On Wed, Nov 17, 2010 at 08:13, Doug Currie <doug.currie@gmail.com> wrote:
>>
>> On Nov 16, 2010, at 11:51 PM, Alexander Gladysh wrote:
>>
>>> I'm looking for the Lua equivalent for this:
>>>
>>> http://www.boost.org/doc/libs/1_44_0/doc/html/tribool.html
>>
>> You can get a long way with using
>
>> true := 1.0
>> false := 0.0
>> indeterminate := NaN
>
> Nice!
>
> But NaN is not a first-class-citizen in Lua.
>
> I think that sooner or later I'll want to do t[indeterminate] = value.
>
> Alexander.
>
>

How about the balanced ternary system:

tri_true= -1
tri_unknown= 0
tri_false= 1

function tri_and(x,y) return max(x,y) end
function tri_or(x,y) return min(x,y) end
function tri_not(x,y) return -x end
function tri_xor(x,y) return x*y end

Hope it helps.
--Leo--