Talk:Palindrome detection: Difference between revisions
Content added Content deleted
(→Haskell recursive solution note: e.g. this) |
(Python recursive example doesn't work) |
||
Line 9: | Line 9: | ||
</pre> |
</pre> |
||
:--[[User:Gaaijz|Gaaijz]] 14:37, 5 December 2008 (UTC) |
:--[[User:Gaaijz|Gaaijz]] 14:37, 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. [[User:Drea|Drea]] 16:56, 5 December 2008 (UTC) |
Revision as of 16:56, 5 December 2008
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)
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)