Hacker News new | ask | show | jobs
by NackerHughes 639 days ago
Why are all the variables functions? They're just numbers. There's no need at all for them to be functions that just return numbers.
1 comments

In this example it might not be so practical, but in calculang everything is a function including constants.

This is because of an emphasis on flexibility. They're a constant here but in another calculang model I can call calculations from this same code while asking for specific pieces of the calculation to be different.

e.g. if I have a population growth assumption then in an exercise I can get all these numbers allowing for population growth - without myself touching these formulas. Population then depends on time and must be a function.

On calculang.dev I say that formulas (functions) are the building blocks of calculations, and they're the mechanism for flexibility (also transparency).