我正在检查一些代码,然后我尝试编写其中一个,但我不断收到解析“=”错误,但是当我从源代码复制粘贴代码时,它工作正常,那么这之间有什么区别?
quicksort2 :: (Ord a) => [a] -> [a]
quicksort2 [] = []
quicksort2 (x:xs) =
let smallerSorted = quicksort2 [a | a <- xs, a <= x]
biggerSorted = quicksort2 [a | a <- xs, a > x]
in smallerSorted ++ [x] ++ biggerSorted
和这个 ;
quicksort :: (Ord a) => [a] -> [a]
quicksort [] = []
quicksort (x:xs) =
let smallerSorted = quicksort [a | a <- xs, a <= x]
biggerSorted = quicksort [a | a <- xs, a > x]
in smallerSorted ++ [x] ++ biggerSorted
quicksort2 得到解析错误,但 quicksort 没有。那么区别在哪里呢?
错误-> .hs:5:26: 输入 `=' 解析错误