Created
December 7, 2016 12:50
-
-
Save zhouqiang-cl/39d2eb1250bf89ce18ddb70a03d4ef1c to your computer and use it in GitHub Desktop.
common lisp 的宏 TYPECASE
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 语法 | |
| 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