(0, 1): {
"CENTER": {"action": "8", "type": "text", "text": "8", },
"SOUTH": {"action": "[**]", "type": "text", "text": "**", },
- "showAllSlices": True,
+ "EAST": {"action": "[sq]", "type": "text", "text": "sq", },
+ "WEST": {"action": "[sqrt]", "type": "text", "text": "sqrt", },
+ "showAllSlices": False,
},
(0, 2): {
"CENTER": {"action": "9", "type": "text", "text": "9", },
},
(2, 2): {
"CENTER": {"action": "3", "type": "text", "text": "3", },
+ "WEST": {"action": "[!]", "type": "text", "text": "!", },
"showAllSlices": True,
},
(3, 0): {
(3, 2): {
"CENTER": {"action": ".", "type": "text", "text": ".", },
"NORTH": {"action": "j", "type": "text", "text": "j", },
+ "WEST": {"action": "[+-]", "type": "text", "text": "+/-", },
"showAllSlices": True,
},
},
exponentiation = operation.generate_function(operator.pow, "**", operation.Function.REP_INFIX, 2)
abs = operation.generate_function(operator.abs, "abs", operation.Function.REP_FUNCTION, 1)
-#factorial = operation.generate_function(math.factorial, "!", operation.Function.REP_POSTFIX, 1)
-
+try:
+ fact_func = math.factorial
+except AttributeError:
+ def fact_func(num):
+ return num * fact_func(num - 1)
+factorial = operation.generate_function(math.factorial, "!", operation.Function.REP_POSTFIX, 1)
+negate = operation.generate_function(operator.neg, "+-", operation.Function.REP_PREFIX, 1)
+square = operation.generate_function((lambda self, x: x ** 2), "sq", operation.Function.REP_FUNCTION, 1)
+square_root = operation.generate_function((lambda self, x: x ** 0.5), "sqrt", operation.Function.REP_FUNCTION, 1)
+
+# @todo Possibly make a graphic for this of x^y
PLUGIN.register_operation("**", exponentiation)
PLUGIN.register_operation("abs", abs)
+PLUGIN.register_operation("!", factorial)
+PLUGIN.register_operation("+-", negate)
+PLUGIN.register_operation("sq", square)
+PLUGIN.register_operation("sqrt", square_root)