Calculator the Right Way
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Calculator the Right Way

So many people argue on this:

As a programmer: this must be thrown syntax error.

As a mathematician: b should considered a multiplicant of (c+d), before all of them being divide by a.

Then why not implement it as the mathematician said? Ok, let's figure out.

How to Use?

Inside this dir, just

python3 calculator

Here is something I recommend you to try out:

>>> 9/3(2+1)
>>> a, b, c, d = 48, 2, 9, 3
>>> a/b(c+d)
>>> 10(9(8(7(6(5(4(3(2(1)))))))))
>>> (1+2j)(3-4j)
>>> 1 + 1/phi
>>> phi(43)

What's Differ from Python?

  • int, float, complex are now callable.
  • real, imag, conjugate became functions.

The Problems!

Since mathematician often use the same symbol in difference context, e.g. φ (phi) can mean for both golden ratio and Euler's totient. At the 1st glance this seems legit -- just use phi ** 2 as a number, while phi(50) stands for function calling, -- but since Python is a 1st class function (also function as object), you can pass those functions as argument everywhere. This means you never figure out omicron(phi) seen phi as number or function. Also phi(5) and 5(phi) does yield different value and can cuase much confusion to newbie.

So this concept should not be implement into real-world programming at all.

See Also