What is wrong with rs definition in first where section?
palindrome :: [a] -> [a] palindrome xs = con xs rs where con a b = rev (rev a []) b rs = rev xs -- here where rev [] rs = rs rev (x:xs) rs = rev xs (x:rs)
I’m just learning Haskell but its syntax rules confuse me. The error message is
[1 of 1] Compiling Main ( pelindrome.hs, interpreted ) pelindrome.hs:5:8: parse error on input `rs'
Your indentation was wrong and i think you can only have one
wherein there (i could be very well wrong. I’m not a haskell guy). There was also a argument missing for the call torev(an empty list):Prints out:
I’m going to try to understand it now. Anyway, have fun!
Edit: Makes perfect sense to me now. I think that’s the right version. For Haskell indentation rules, read Haskell Indentation