lua-users home
lua-l archive

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


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 :)