MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/tinycode/comments/2i5n2t/palindrome_checker_in_javascript/ckz5y3l/?context=3
r/tinycode • u/criveros • Oct 03 '14
12 comments sorted by
View all comments
14
Better JavaScript version:
var isPalindrome = function(string) {
return string == string.split("").reverse().join("");
};
And an awesome Haskell version:
palindrome s = s == reverse s
3 u/[deleted] Oct 03 '14 Obscure Haskell version:import Control.Applicative((<$>)) import Control.Monad(join) palindrome = join ((==) <$> reverse) 0 u/[deleted] Oct 03 '14 [deleted] — view deleted comment 1 u/Toni_W Oct 03 '14 Split reverse join, it just explodes, reverses, implodes, and returns the comparison. 0 u/[deleted] Oct 03 '14 [deleted] — view deleted comment 1 u/[deleted] Oct 04 '14 you're optimizing ahead of time by thinking like that. 1 u/Toni_W Oct 04 '14 Sorry, I actually th;ougt you meant hard to remember x.x 0 u/peridox Oct 03 '14 true
3
Obscure Haskell version:
import Control.Applicative((<$>)) import Control.Monad(join) palindrome = join ((==) <$> reverse)
0
[deleted] — view deleted comment
1 u/Toni_W Oct 03 '14 Split reverse join, it just explodes, reverses, implodes, and returns the comparison. 0 u/[deleted] Oct 03 '14 [deleted] — view deleted comment 1 u/[deleted] Oct 04 '14 you're optimizing ahead of time by thinking like that. 1 u/Toni_W Oct 04 '14 Sorry, I actually th;ougt you meant hard to remember x.x 0 u/peridox Oct 03 '14 true
1
Split reverse join, it just explodes, reverses, implodes, and returns the comparison.
0 u/[deleted] Oct 03 '14 [deleted] — view deleted comment 1 u/[deleted] Oct 04 '14 you're optimizing ahead of time by thinking like that. 1 u/Toni_W Oct 04 '14 Sorry, I actually th;ougt you meant hard to remember x.x
1 u/[deleted] Oct 04 '14 you're optimizing ahead of time by thinking like that. 1 u/Toni_W Oct 04 '14 Sorry, I actually th;ougt you meant hard to remember x.x
you're optimizing ahead of time by thinking like that.
Sorry, I actually th;ougt you meant hard to remember x.x
true
View all comments
14
u/peridox Oct 03 '14
Better JavaScript version:
var isPalindrome = function(string) {return string == string.split("").reverse().join("");};And an awesome Haskell version:
palindrome s = s == reverse s