SketchyLISP Stuff | Copyright (C) 2006 Nils M Holm |
[ More Sketchy LISP Stuff ] |
Conformance: R5RS
Purpose: Compute a hyperN b. A, b, and n must all be natural numbers.
Arguments:
N - integer (order)
A - integer (base)
B - integer (hyper-exponent)
Implementation:
(define (hyper n a b) (cond ((= n 0) (+ b 1)) ((= n 1) (+ a b)) ((= b 1) a) ((= n 2) (* a b)) ((= n 3) (expt a b)) ((= n 4) (expt a (hyper n a (- b 1)))) ((> n 4) (hyper (- n 1) a (hyper n a (- b 1)))))) ; (defun hyper4 (a b) (hyper 4 a b)) ; (defun hyper5 (a b) (hyper 5 a b)) ; ...
Example:
(hyper 4 3 3) => 7625597484987
[ More Sketchy LISP Stuff ] |