Fri, 24 Apr 2015 06:40:08 +0300
Added sgn(x) to .calc
calc.py | file | annotate | diff | comparison | revisions |
--- a/calc.py Sun Apr 19 22:46:39 2015 +0300 +++ b/calc.py Fri Apr 24 06:40:08 2015 +0300 @@ -134,6 +134,9 @@ else: OperatorSymbols[op.symbol] = [op] +def sgn (x): + return cmp (x, 0) + Constants = { 'pi': cmath.pi, 'e': cmath.e, @@ -177,6 +180,7 @@ 'im': { 'function': lambda x: x.imag }, 'conjugate':{ 'function': lambda x: x.conjugate() }, 'rand': { 'function': random.random }, + 'sgn': { 'function': realf (sgn) }, } Tokens = ['(', ')']