t3x.org / sketchy / prog / hyper.html
SketchyLISP Stuff Copyright (C) 2007 Nils M Holm

hyper

Language: R5RS Scheme

Purpose: Implement the hyperN operator. 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))))))

; (define (hyper4 a b) (hyper 4 a b))
; (define (hyper5 a b) (hyper 5 a b))
; ...

Example:

(hyper 4 3 3) 
=> 7625597484987