Created
November 30, 2016 10:47
-
-
Save zhouqiang-cl/36a29bb4ae6342dc68d1e945211b6336 to your computer and use it in GitHub Desktop.
common lisp 的函数 MAPHASH
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
语法 | |
maphash function hash-table => nil | |
参数和值 | |
function --- 一个函数指示符, 这个函数接受两个参数 key 和 value | |
hash-table --- 一个hash table | |
描述 | |
遍历 hash table 的每一个 entry, 对使用 key 和 value 对函数进行调用 | |
代码 | |
* (setq table (make-hash-table)) | |
#<HASH-TABLE :TEST EQL :COUNT 0 {1004AD8603}> | |
* (dotimes (i 10) (setf (gethash i table) i)) | |
NIL | |
* (maphash #'(lambda (k v) (print (list k v))) table) | |
(0 0) | |
(1 1) | |
(2 2) | |
(3 3) | |
(4 4) | |
(5 5) | |
(6 6) | |
(7 7) | |
(8 8) | |
(9 9) | |
NIL | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment