Palindrome detection: Difference between revisions

Content deleted Content added
Rob-codes (talk | contribs)
added Emacs Lisp code that works with inexact palindromes
Rob-codes (talk | contribs)
No edit summary
Line 2,021:
The version below will work correctly with inexact palindromes, as defined in this exercise:
 
<syntaxhighlight lang="lisp">
<pre>
(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>
</pre>
{{out}}