defun 定義匹配

使用模式匹配,可以將函式定義和模式匹配交織在一起,類似於 SML。

(trivia:defun-match fib (index)
  "Return the corresponding term for INDEX."
  (0 1)
  (1 1)
  (index (+ (fib (1- index)) (fib (- index 2)))))

(fib 5)
;; => 8