;;; -*- mode: lisp -*- ;;; $Id: ackermann.poplisp,v 1.0 2002/05/03 12:03:00 dada Exp $ (defun fast-ack (m n) (declare (fixnum n m) (optimize (speed 3) (debug 0) (safety 0))) (the fixnum (cond ((zerop m) (the fixnum (1+ n))) ((zerop n) (the fixnum (fast-ack (1- m) 1))) (t (the fixnum (fast-ack (1- m) (the fixnum (fast-ack m (1- n))))))))) ;(defun ack (m n) ; (cond ; ((zerop m) (1+ n)) ; ((zerop n) (ack (1- m) 1)) ; (t (ack (1- m) (ack m (1- n)))))) (let ((n (parse-integer (or (car pop11::poparglist) "1")))) (format *standard-output* "Ack(3,~A): ~A~%" n (fast-ack 3 n)) )