Introduced a recent project and then dug into all the details. Why was it designed this way? How was this feature implemented? Digging into each detail and how it was implemented took about 30 minutes.
There are thousands of functions. The input is two numbers. The operation is a mathematical operation. For example, the first one is A times B, the second one is A times B times B times B times B, and the third one is A times B + A times B times B.
How to efficiently store all the operation results? Where to store them? At the same time, it is necessary to avoid repeated calculations. Different input orders are considered different operations. For example,
function1 (100,1000) → operation
function1 (100,1000) → no operation
function1 (1000.100) → operation
function2 (100,1000) →
operation function3 (100,1000) → operation
function2 (100,1000) → no operation