lua-users home
lua-l archive

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


On Thu, Mar 27, 2014 at 7:32 PM, Peng Zhicheng
<pengzhicheng1986@gmail.com> wrote:
> On 03/28/2014 06:42 AM, Elias Barrionovo wrote:
>>
>> This is a quick hack based on something I once had to do in Python,
>> because Lua didn't have overloadable bitwise ops... until now! =D
>>
>> Lpredicate allows the building of boolean expressions on predicates,
>> wich are basically lua functions wrapped as tables with some bitwise
>> ops:
>>
>> --
>> even = predicate(function (n) return n % 2 == 0 end)
>> greater100 = predicate(function (n) return n > 100 end)
>>
>> (even & greater100)(150) --> true
>> (even & greater100)(80) --> false
>> (even & ~greater100)(80) --> true
>> --
>>
>> Code can be found at github: https://github.com/etandel/lpredicate
>>
>>
> seems interesting.
>
> I'll check it so see whether I can integrate that into my unit testing
> infrustructure.
> but firstly, I should test my code under Lua 5.3 :)
>

I keep thinking I want to use the binary-not operator (~) like the
spaceship operator (<=>).  Would be fun :-)