我得到
解析错误(可能是不正确的缩进或不匹配的括号(
与| 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