2 - Define
a LISP function to solve Ackermann’s function
Implementation Code in LISP -
(defun ackermann ( m n ) “The Ackermann Function”
(cond ((= m 0) (+ n 1))
((= m 1) (+ n 2))
((= m 2) (+
3( * n 2)))
((=
m 3) (+ 5 (* 8( - (expt 2 n) 1))))
(t (cond ((= n 0) (Ackermann (- m 1) 1))
(t (Ackermann (- m 1) (Ackermann m (- n 1))))
))))
OUTPUT-
(Ackermann 2 3)
9
No comments:
Post a Comment