Palindrome detection: Difference between revisions
Content deleted Content added
added Emacs Lisp code that works with inexact palindromes |
No edit summary |
||
Line 2,021:
The version below will work correctly with inexact palindromes, as defined in this exercise:
<syntaxhighlight lang="lisp">
(defun test-if-palindrome (text)
(setq text (replace-regexp-in-string "[[:space:][:punct:]]" "" text)) ; remove spaces and punctuation, by replacing them with nothing
(string-equal-ignore-case text (reverse text))) ; ignore case when looking at reversed text
</syntaxhighlight>
{{out}}
|