logo
  • 教程列表
  • SO官方文档
  • 模式匹配
    • 概述
    • 调度 Clack 请求
    • defun 定义匹配
    • 构造函数模式
    • 警卫模式
  1. StackOverflow 文档
  2. common-lisp 教程
  3. 模式匹配
  4. defun 定义匹配

defun 定义匹配

Created: November-22, 2018

使用模式匹配,可以将函数定义和模式匹配交织在一起,类似于 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
  • 构造函数模式
  • 调度 Clack 请求

Copyright © 2018. All right reserved

tastones.com 备案号:鲁ICP备18045372号-1

  • 关于我们
  • 免责声明