# HG changeset patch # User Teemu Piippo # Date 1429846808 -10800 # Node ID 7349e9c6176b7c13ebdf1cde4171a78b2c11efc7 # Parent c82cef74700861ed5615ca13f0d8d9bf8a71967d Added sgn(x) to .calc diff -r c82cef747008 -r 7349e9c6176b calc.py --- 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 = ['(', ')']