28 ms·
> Consider: > 45 * 7 + 60 * 8 Any compiler that is beyond toy quality reduces that to 795. So should the programmer; the only reason to leave it in a * b + c
by kazinator 3y ago
> Consider:
> 45 * 7 + 60 * 8
Any compiler that is beyond toy quality reduces that to 795.
So should the programmer; the only reason to leave it in a * b + c * d form would be if it actually looks that way due to symbolic constants being used. The compiler still gets us the 795 so there is no run-time calculation.
Then in that form, there is no common factor to remove: the expressions a and c don't have a common factor.
- carapace 3y agoOf course. I'm just using the simple high school algebra as a kind of metaphor or analogy to the similar concepts and operations in e.g. Lambda Calculus-based PLs. They're formalized in Category Theory but I didn't want to get into all that.