lua-users home
lua-l archive

[ANN] LPredicate - Library for composing predicates

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


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
-- 
NI!
() - www.asciiribbon.org
/\ - ascii ribbon campaign against html e-mail and proprietary attachments

AltStyle によって変換されたページ (->オリジナル) /