Fixing a bug for when math.factorial isn't available
authorepage <eopage@byu.net>
Thu, 30 Apr 2009 03:21:38 +0000 (03:21 +0000)
committerepage <eopage@byu.net>
Thu, 30 Apr 2009 03:21:38 +0000 (03:21 +0000)
git-svn-id: file:///svnroot/ejpi/trunk@36 df6cc7de-23d0-4ae0-bb86-c17aa67b2a9d

src/plugins/builtins.py
support/builddeb.py

index d464e9d..f57520e 100644 (file)
@@ -29,9 +29,11 @@ abs = operation.generate_function(operator.abs, "abs", operation.Function.REP_FU
 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)
+       def fact_func(self, num):
+               if num <= 0:
+                       return 1
+               return num * fact_func(self, num - 1)
+factorial = operation.generate_function(fact_func, "!", 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)
index fc45870..ec08df7 100755 (executable)
@@ -8,7 +8,7 @@ __description__ = "A Touch Screen Optimized RPN Calculator using Pie Menus"
 __author__ = "Ed Page"
 __email__ = "eopage@byu.net"
 __version__ = "0.9.3"
-__build__ = 0
+__build__ = 1
 __changelog__ = '''
 0.9.3 - ""
  * Added +/-, !, sq, and sqrt functions