Skip to content

Instantly share code, notes, and snippets.

;; A version of the ackermann function, described in https://u.osu.edu/friedman.8/files/2014/01/LongFinSeq98-2f0wmq3.pdf
(require '[clojure.core.match :refer [match]])
(defn ackermann [[k & r :as s] n]
(if (not (seq s))
n
(match [k n]
[1 _] (recur r (*' 2 n))
[_ 1] (recur (cons (dec k) r) 1)