Refactor elisp/anagram/anagrams-for

Reformat.

Use push macro over low-level list-manipulation.
This commit is contained in:
dwrz
2019-02-05 02:29:37 +00:00
parent 7ab5ac1638
commit bd7d8a2ccb
+4 -6
View File
@@ -35,12 +35,10 @@ Case insensitive."
(let ((candidates ())
(word-char-count (get-char-count (downcase word))))
(dolist (candidate anagrams candidates)
(if (and
(not (string-equal word candidate))
(equal (length word) (length candidate))
(when (and (not (string-equal word candidate))
(= (length word) (length 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)))))))
(push candidate candidates)))
(reverse candidates)))
;;; anagram.el ends here