Let's say I've got many functions and each function accepts an unordered list (order does not matter). For each function I want to see if this list is valid based on certain rules (a knowledgebase that has the rules for each function's list).
Each one of this lists is at its core a combination, right? And each combination can be:
- Not valid due to a certain element not being acceptable
- Not valid due to some combination not being acceptable (let's say I allow [1, 2] and [1, 3] but [2, 3] is not acceptable)
I'm trying to find a way to:
Have each set of rules/possibilities in a knowledgebase, that can be updated whenever I want (maybe reading from a file? I would actually prefer a DSL to write the rules, if possible) and can be loaded at startup
A way to validate these rules/possibilities in an intelligent and elegant manner and not resorting to nested if else's and the such.
fun_1([a, b, c]) : check_knowledgebase([a, b, c]) # => valid fun_1([a, b, d]): check_knowledgebase([a, b, d]) # => element d is invalid fun_1([a, c, d]): check_knowledgebase([a, c, d]) # => combining c with d is invalid
I've been thinking about this but I don't know what kind of theory or algorithms I should look into for this. I thought about Rule Engines, but implementing one would be too time consuming for something so small?
EDIT: I'm not exactly looking for a language specific solution, I want a solution that is mostly language agnostic.