与 let 在线解析错误(可能是不正确的缩进或不匹配的括号)
parse error (possibly incorrect indentation or mismatched brackets) on line with let
我明白了
parse error (possibly incorrect indentation or mismatched brackets)
与| i > j = do swap axs p j
一致
apartition :: Ord a => STArray s Int a -> Int -> Int -> ST s Int
apartition axs p q = do
x <- readArray axs p
let loop i j
| i > j = do swap axs p j
return j
| otherwise = do u <- readArray axs i
if u < x
then do loop (i + 1) j
else do swap axs i j
loop i (j − 1)
loop (p + 1) q
我真的很困惑这是什么原因,有人能帮我解决一下吗?
这是一个缩进错误,你需要在 loop
的定义开始的右边放置至少一个字符,所以:
apartition :: Ord a => STArray s Int a -> Int -> Int -> ST s Int
apartition axs p q = do
x <- readArray axs p
let loop i j
| i > j = do swap axs p j
return j
| otherwise = do u <- readArray axs i
if u < x
then do loop (i + 1) j
else do swap axs i j
loop i (j - 1)
loop (p + 1) q
我明白了
parse error (possibly incorrect indentation or mismatched brackets)
与| i > j = do swap axs p j
apartition :: Ord a => STArray s Int a -> Int -> Int -> ST s Int
apartition axs p q = do
x <- readArray axs p
let loop i j
| i > j = do swap axs p j
return j
| otherwise = do u <- readArray axs i
if u < x
then do loop (i + 1) j
else do swap axs i j
loop i (j − 1)
loop (p + 1) q
我真的很困惑这是什么原因,有人能帮我解决一下吗?
这是一个缩进错误,你需要在 loop
的定义开始的右边放置至少一个字符,所以:
apartition :: Ord a => STArray s Int a -> Int -> Int -> ST s Int
apartition axs p q = do
x <- readArray axs p
let loop i j
| i > j = do swap axs p j
return j
| otherwise = do u <- readArray axs i
if u < x
then do loop (i + 1) j
else do swap axs i j
loop i (j - 1)
loop (p + 1) q