[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: [ANN] LPredicate - Library for composing predicates
- From: Elias Barrionovo <elias.tandel@...>
- Date: Thu, 27 Mar 2014 19:42:00 -0300
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