Skip to content

Instantly share code, notes, and snippets.

@zhouqiang-cl
Created December 7, 2016 12:50
Show Gist options
  • Select an option

  • Save zhouqiang-cl/39d2eb1250bf89ce18ddb70a03d4ef1c to your computer and use it in GitHub Desktop.

Select an option

Save zhouqiang-cl/39d2eb1250bf89ce18ddb70a03d4ef1c to your computer and use it in GitHub Desktop.
common lisp 的宏 TYPECASE
语法
typecase keyform {normal-clause}* [otherwise-clause] => result*
参数和值
keyform --- 一个 form, 会被求值去产生一个 test-key
描述
待补充
代码
* (defun what-is-it (x)
(format t "~&~S is ~A.~%"
x (typecase x
(float "a float")
(null "a symbol, boolean false, or the empty list")
(list "a list")
(t (format nil "a(n) ~(~A~)" (type-of x))))))
WHAT-IS-IT
* (map 'nil #'what-is-it '(nil (a b) 7.0 7 box))
NIL is a symbol, boolean false, or the empty list.
(A B) is a list.
7.0 is a float.
7 is a(n) (integer 0 4611686018427387903).
BOX is a(n) symbol.
NIL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment