3 ms·
You can get the same effect if you model the expression as a free algebra (ADT). You can then simplify the terms in the same way. The paper: "The design of a p
by wfdctrl 6y ago
You can get the same effect if you model the expression as a free algebra (ADT). You can then simplify the terms in the same way.
The paper: "The design of a pretty printing library", by Hughes, explains this nicely.
The main difference is that algebras are more natural in FP and coalgebras in OOP, but they can mostly do the same things, just a bit differently. Actually you can also do algebras in OOP as well (visitor pattern) and coalgebras is FP.
Basically my point was that you should use the simplest abstraction that gets the job done. Even if you implemented max and pow as objects, for your specific use case, you would probably just call the pure functions inside.
Thank you for the book recommendation.