#!/usr/local/bin/guile \
-e main -s
!#
;;; $Id: ackermann.guile,v 1.9 2001/06/29 23:12:36 doug Exp $
;;; http://www.bagley.org/~doug/shootout/

(debug-set! stack 0)

(define (main args)
  (let ((n (or (and (= (length args) 2) (string->;number (cadr args))) 1)))
    (print-list "Ack(3," n "): " (ack 3 n))))

(define (ack m n)
  (cond ((zero? m) (+ n 1))
    ((zero? n) (ack (- m 1) 1))
    (else      (ack (- m 1) (ack m (- n 1))))))

(define (print-list . items) (for-each display items) (newline))