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

  • 關於本站
  • 免責聲明