Emacs Lisp中的hash table

(defun zj-hash-test ()
  "hash table 测试"
  (interactive)
  (let (myhash val)
    ;; 创建hash table并告诉elips用equal来测试key是否存在
    (setq myhash (make-hash-table :test 'equal))

    ;; 添加数据
    (puthash "key1" "19" myhash)
    (puthash "key2" "1ddd" myhash)
    (puthash "key3" "1te" myhash)
    (puthash "key4" "19" myhash)


    ;; 修改数据
    (puthash "key1" "2334dd" myhash)

    ;; 删除数据
    (remhash "key3" myhash)

    ;; 获取数据
    (setq val (gethash "key2" myhash))
    (message val)
    )
  )

你可能感兴趣的:(emacs,lisp)