Talk:Palindrome detection: Difference between revisions

Line 7:
: I think what is meant is that the function itself shouldn't ignore spaces or punctuations, but if using the given example, the test code must remove spaces and convert to either uppercase or lowercase, because otherwise the example isn't a character-wise palindrome. I think it would make more sense to use some example which already is a character-wise palindrome by itself, say the German word "nennen" (to name). --[[User:Ce|Ce]] 09:42, 6 December 2008 (UTC)
 
:: It is what I've meant... As example of palindrome I used "In girum imus ..." just because it is the longest I know by heart: the "ignore or strip spaces" refers to that example as I wrote there; looking at the code it is clear what I've meant. According to me a function that tests the palindromicity of a "arbitrary" sequence is more general than one that "ignores" by design some characters; you can use the function you wrote to test palindromicity on "In girum imus nocte ...", provided that you strip spaces and make the case of all letters the same... outside the function, e.g. is_palindrome(stripchars(string)), and write stripchars according to any need. In the codes, I did it by hand coding the test string as "ingirumimusnocte...", that is less readable, but in this way I had not to write a stripchars function just to test! --[[User:ShinTakezou|ShinTakezou]] 00:44, 7 December 2008 (UTC)
 
:: And hey, my english is bad, but not so bad: I've forgot it, but I wrote ''To do your test with it, you must make it all the same case and strip spaces.'', where the "it" refers to the "In girum imus..." palindrome, and ''to do your test with it'' means ... :D --[[User:ShinTakezou|ShinTakezou]] 00:44, 7 December 2008 (UTC)
Line 14:
 
:::: Got your point. Chances there are that my ''main'' contribute is in the C language :) --[[User:ShinTakezou|ShinTakezou]] 00:25, 8 December 2008 (UTC)
 
::: I'm afraid I have to disagree with ShinTakezou on this. The normal, non-computational definition of a palindrome is a string that reads the same forwards and backwards while ignoring spaces, case and punctuation. So the computational definition should be the same for this task. Especially since stripping non-word chars is a common subtask. If the input has to be massaged manually for a checker to work, it's not much of a checker. :-) And checking only single-word strings is really just a degenerate case. --[[User:Snoman|Snoman]] 00:43, 13 July 2010 (UTC)
 
----
 
Looking at the Perl, adding case/space/punctuation handling to the first 3 functions is a 1-line fix in each that doesn't change the existing functionality. Done. The last Regex solution is a different story, besides the misspelling of palindrome. :-) I don't quite understand the argument logic yet, and the regex doesn't even compile for me. Checking into this.
--[[User:Snoman|Snoman]] 00:43, 13 July 2010 (UTC)
 
==Haskell recursive solution note==
Anonymous user