Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Calculator the Right Way
Python
branch: master

fix pic

latest commit d3156be3ac
@neizod authored
Failed to load latest commit information.
LICENSE.txt add license
README.md fix pic
calculator.py also hook callnum into builtins
callnum.py fix str manipulation w/ number

README.md

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)
1.0
>>> a, b, c, d = 48, 2, 9, 3
>>> a/b(c+d)
2.0
>>> 10(9(8(7(6(5(4(3(2(1)))))))))
3628800
>>> (1+2j)(3-4j)
(11+2j)
>>> 1 + 1/phi
1.618033988749895
>>> phi(43)
42

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

Something went wrong with that request. Please try again.