rs
定義中的第一個where部分有什麼問題?Haskell語法分析程序錯誤,在where子句中
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)
我剛剛學習Haskell,但它的語法規則讓我困惑。該錯誤消息是
[1 of 1] Compiling Main (pelindrome.hs, interpreted)
pelindrome.hs:5:8: parse error on input `rs'
你說得對,rs必須從前一行的con開始。這是奇怪的規則。 – 2009-01-05 11:52:24
不奇怪:同樣的語法層次 - >相同的縮進 – Svante 2009-01-05 12:04:25