commit ca9c5f7d5104a49d646dc6dc4c198d23eac979ee parent a2bca632e8016eceed2029d3c874475e7e7f32ef Author: dwrz <dwrz@dwrz.net> Date: Sun, 20 Jan 2019 19:38:32 +0000 Refactor elisp/anagram/anagrams-for Diffstat:
M | elisp/anagram/anagram.el | | | 6 | ++++-- |
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/elisp/anagram/anagram.el b/elisp/anagram/anagram.el @@ -31,13 +31,15 @@ CHAR-COUNT and COMPARISON-CHAR-COUNT should be alists in (character . count) for (setq are-equal nil))))) (defun anagrams-for(word anagrams) + "Return all elements of ANAGRAMS which are anagrams for WORD. +Case insensitive." (let ((candidates ()) - (word-char-count (make-char-count word))) + (word-char-count (get-char-count (downcase word)))) (dolist (candidate anagrams candidates) (if (and (not (string-equal word candidate)) (equal (length word) (length candidate)) - (compare-char-counts word-char-count (make-char-count candidate))) + (equal-char-count word-char-count (get-char-count (downcase candidate)))) (if (> (length candidates) 0) (add-to-list 'candidates candidate t) (setq candidates (cons candidate nil)))))))