Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defstruct (key-chord (:conc-name nil))
- key-code key-string modifiers)
- (defun key-chord-hash (kc)
- (let ((factors (list char-code-limit (expt 2 8) 1)))
- (reduce (function +)
- (mapcar (function *)
- factors
- (list
- ;; I assume key-string and modifers are short sequences, so sxhash will be ok.
- (sxhash (key-string kc))
- (sxhash (key-code kc))
- (sxhash (modifiers kc)))))))
- (mapcar (function key-chord-hash)
- (list (make-key-chord :key-code 108 :key-string "l" :modifiers '())
- (make-key-chord :key-code 65 :key-string "A" :modifiers '(c))
- (make-key-chord :key-code 65 :key-string "A" :modifiers '(c m))))
- ;; --> (8482891512445 4956500734673 4956500734851)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement