Talk:Palindrome detection: Difference between revisions
Content added Content deleted
No edit summary |
(Spaces and punctuation) |
||
Line 1: | Line 1: | ||
==Spaces and punctuation== |
|||
The task specification states both:"The function must not ignore spaces and punctuations" and later: |
|||
"you must make it all the same case and strip spaces". |
|||
So ignore or strip spaces - what should be done? --[[User:Paddy3118|Paddy3118]] 20:56, 5 December 2008 (UTC) |
|||
==Haskell recursive solution note== |
==Haskell recursive solution note== |
||
Revision as of 20:56, 5 December 2008
Spaces and punctuation
The task specification states both:"The function must not ignore spaces and punctuations" and later: "you must make it all the same case and strip spaces".
So ignore or strip spaces - what should be done? --Paddy3118 20:56, 5 December 2008 (UTC)
Haskell recursive solution note
I suppose the Haskell recursive code can be written a lot better, but I don't know how. --ShinTakezou 14:08, 5 December 2008 (UTC)
- Does this look better to you?
is_palindrome_r x | length x <= 1 = True | head x == last x = is_palindrome_r . tail. init $ x | otherwise = False
- --Gaaijz 14:37, 5 December 2008 (UTC)
- Yes, if it works, why don't you put it in? I've tested it, it works, put it in instead of mine ;) --ShinTakezou 19:09, 5 December 2008 (UTC)
The Python recursive example isn't testing that the string is a palindrome. It seems to actually be a test for whether the object tested supports len() and slicing. Drea 16:56, 5 December 2008 (UTC)
- Why? I am still learning Python... even though there's no type check (right?) I suppose the normal use of such a function is on strings or arrays, both supporting len and slicing; maybe it makes sense to be able to test palindromicity also on other objects. Anyway it worked rather well when tested ;) --ShinTakezou 19:09, 5 December 2008 (UTC)
- It looks like the Perl example doesn't check for character equality either. --Mwn3d 16:59, 5 December 2008 (UTC)
- Oh my ... yes, thanks (the same as Python... can't remember if I simply forgot or were cut... fixing --ShinTakezou 19:09, 5 December 2008 (UTC)
- I've fixed the Python example. I don't know any Perl though, so I'll leave that for someone else. Drea 17:03, 5 December 2008 (UTC)
- Oh my ... yes, thanks :) --ShinTakezou 19:09, 5 December 2008 (UTC)
- No problem :o) Drea 19:29, 5 December 2008 (UTC)
- Oh my ... yes, thanks :) --ShinTakezou 19:09, 5 December 2008 (UTC)