Commit 8a78a9a1 authored by Liam M. Healy's avatar Liam M. Healy
Browse files

Fix infinite recursion in negation

Do negation by multiplying by -1 rather than finding the negative of
the second argument recursively, which overflows the stack.
parent 821bf3cf
;; Generic functions arithmetic functions on generalized numbers
;; Liam Healy Tue Feb 9 1999 - 21:38
;; Time-stamp: <2014-01-05 14:14:06EST generic.lisp>
;; Time-stamp: <2014-07-10 10:17:09EDT generic.lisp>
;; Copyright 2011, 2013, 2014 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
......@@ -83,7 +83,7 @@
(defun - (&rest args)
"Subtraction of generalized or regular numbers."
(when (member nil args) (warn 'null-argument))
(if (single args) (-i 0 (first args)) (reduce #'-i args)))
(if (single args) (*i -1 (first args)) (reduce #'-i args)))
(defgeneric *i (a b)
(:documentation "Multiplication of generalized or regular numbers.")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment