Advertisement
Guest User

Untitled

a guest
Dec 17th, 2018
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. (defstruct (key-chord (:conc-name nil))
  2. key-code key-string modifiers)
  3.  
  4. (defun key-chord-hash (kc)
  5. (let ((factors (list char-code-limit (expt 2 8) 1)))
  6. (reduce (function +)
  7. (mapcar (function *)
  8. factors
  9. (list
  10. ;; I assume key-string and modifers are short sequences, so sxhash will be ok.
  11. (sxhash (key-string kc))
  12. (sxhash (key-code kc))
  13. (sxhash (modifiers kc)))))))
  14.  
  15. (mapcar (function key-chord-hash)
  16. (list (make-key-chord :key-code 108 :key-string "l" :modifiers '())
  17. (make-key-chord :key-code 65 :key-string "A" :modifiers '(c))
  18. (make-key-chord :key-code 65 :key-string "A" :modifiers '(c m))))
  19. ;; --> (8482891512445 4956500734673 4956500734851)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement