Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/neizod/calculator
Calculator the Right Way
https://github.com/neizod/calculator
Last synced: about 1 month ago
JSON representation
Calculator the Right Way
- Host: GitHub
- URL: https://github.com/neizod/calculator
- Owner: neizod
- License: wtfpl
- Created: 2012-12-13T22:56:14.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2014-04-10T02:15:36.000Z (over 10 years ago)
- Last Synced: 2023-03-12T07:48:25.843Z (over 1 year ago)
- Language: Python
- Size: 148 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
Calculator the Right Way
========================So many people argue on this:
![](http://i1.kym-cdn.com/photos/images/original/000/206/784/6de.jpg)
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)
42What'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
---------