??? 09/04/07 16:07 Modified: 09/04/07 16:18 Read: times Msg Score: +1 +1 Informative |
#143999 - Lookup tables are good for lots of stuff Responding to: ???'s previous message |
Joseph said:
If memory were still priced at a premium, and a look up table was just prohibitive or downright not possible, you could still accomplish the task by doing the calculations each time. This sentence and a couple of other comments in this thread seem to make an assumption that I think a lot of people make, namely that the lookup table is being used to evaluate some slow-to-calculate function by grabbing precomputed values from the table. If you make that assumption, Joe has a good point: you can do the calculations without the lookup table, but you can't have the lookup table without doing the calculations at least once so you know what to put in the table. That's all fine, except that lookup tables have other uses besides the textbook one that everybody talks about. The state table in this example is a lookup table, and not one that could be replaced by some sort of calculation. As another example, consider some sort of invoicing system, where the customer gets a discount based on his volume, with totally arbitrary price breaks. Such a thing would be a snap to implement with a table containing the discount schedule, but probably impossible to calculate. Bottom line: Don't limit your thinking about lookup tables to the classic case of, "Hey, let's precompute the sine function so we don't have to calculate it a runtime." They're (perhaps more) useful in lots of other situations as well. -- Russ |