File: acker.scm

package info (click to toggle)
elk 3.99.8-2
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 5,004 kB
  • sloc: ansic: 22,294; lisp: 6,208; makefile: 821; sh: 171; awk: 154; cpp: 92
file content (14 lines) | stat: -rw-r--r-- 221 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
;;; -*-Scheme-*-
;;;
;;; The Ackermann function

(define (acker x y)
  (cond
    ((zero? x)
      (+ y 1))
    ((zero? y)
      (acker (- x 1) 1))
    (else
      (acker (- x 1) (acker x (- y 1))))))

(print (acker 3 2))