Decision tables: Difference between revisions

m
→‎Comments: clarify extent of axes
m (→‎Comments: clarify extent of axes)
Line 54:
The only interesting line in this solution is the one that assigns <tt>RULE_TABLE</tt>. The rest is mostly ancillary support. This is because the task highlights some freedoms J's multidimensional nature provides to the programmer.
 
Here, we create an array with as many axes (dimensions) as there are rules (questions), plus one. All axes, except the last, have 2 valuespoints (to wit: false, true & false). The last axis contains a boolean vector indicating which actions to try (or not). Thus, J's multidimensional array is leveraged as a tree, and the user's answers provide a path to a leaf (which is accessed arraywise, i.e. all at once).
 
For large numbers of rules and few actions, J's native support of sparse arrays might provide a performance advantage, particularly in space. A minor note about the implementation here: the verb (function) <tt>troubleshoot</tt> is generalized, and reusable on any set of rule table, questions, and suggested actions. The default is to use those given in the printer troubleshooting table.
Anonymous user