File: acker.scm

package info (click to toggle)
elk 3.0-6
  • links: PTS
  • area: main
  • in suites: potato, slink
  • size: 4,068 kB
  • ctags: 3,123
  • sloc: ansic: 20,686; lisp: 5,232; makefile: 419; awk: 91; sh: 21
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))