quickSort.hs:4:1:
parse error (possibly incorrect indentation or mismatched brackets)
quickSort.hs:4:54: parse error on input `='
Two ways to avoid the above error:
1: Haskell expects right indentation.
2: Shouldn't use 'Tab Spacing' for indentation. We must use space bar.
The indentation error occurs only for specific keywords. The 'let' keyword expects the next line to be indented. And then the 'in' keyword should start the same column as 'let' starts.
I don't know why we shouldn't use 'Tab' for indentation. I got the above error because I used the 'Tab Spacing'. Used space bar and solved the problem.
Correct Version:
parse error (possibly incorrect indentation or mismatched brackets)
quickSort.hs:4:54: parse error on input `='
Two ways to avoid the above error:
1: Haskell expects right indentation.
2: Shouldn't use 'Tab Spacing' for indentation. We must use space bar.
The indentation error occurs only for specific keywords. The 'let' keyword expects the next line to be indented. And then the 'in' keyword should start the same column as 'let' starts.
I don't know why we shouldn't use 'Tab' for indentation. I got the above error because I used the 'Tab Spacing'. Used space bar and solved the problem.
Correct Version:
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
No comments:
Post a Comment