;; ackerman function

;;AUTOLOAD: ackerman
;;AUTODOC: ackerman "ackerman function, traditional programming language test"
;;(ackerman number1 number2)
;;
;;A terribly compute-intensive function, useful for tests.
;;Warning, it is also quite memory and stack intensive, too!
;;(ackerman 3 6) is roughly as time-consuming as (fib 25), but is the max you 
;;can go with the limits of the default stack size

(defun ackerman (m n)
        (if (= 0 m) (+ 1 n)
              (= 0 n) (ackerman (- m 1) 1)
              (ackerman (- m 1) (ackerman m (- n 1)))))

;; less memory hungry one

(defun ackerman-lite (m n &aux res)
        (if (= 0 m) (+ 1 n)		; manny.bagnas@sandiegoca.ncr.com
              (= 0 n) (ackerman-lite (- m 1) 1)
    (progn (setq res (ackerman-lite m (- n 1)))
      (setq res (ackerman-lite (- m 1) res))
      res
)))
