3

This is a Quicksort function. But I've got an error at 5:46

--sort function
quicksort [] = []
quicksort (x:xs) = (quicksort lesser) ++[x] ++ (quicksort greater)
                      where lesser = filter (<) xs
                                 greater = filter (>=) xs

What's the problem? It seems that the function is correct.

1
  • Due to immutability, this actually isn't a Quicksort function, but that's a discussion for when you're more comfortable with the language.
    – rtperson
    Oct 21, 2011 at 21:08

1 Answer 1

4

It appears you have a simple whitespace error.... lesser and greater need to be indented equally, so that they begin on the same column.

6
  • But they are intended equally. it's only here they are not equal Oct 21, 2011 at 21:03
  • you must have a tab character somewhere, because when they are not indented equally, that is the exact error I receive. Oct 21, 2011 at 21:04
  • 3
    @Артём Царионов - Make sure you're using spaces instead of tabs. You can set this up in your editor if you're worried about your thumbs. When the tabs are gone from your source code, then you'll know if your indentation is correct or not.
    – rtperson
    Oct 21, 2011 at 21:06
  • 1
    @Артём Царионов I don't use Windows, so I'm not sure your best option, but I'm sure it's not Notepad. This question may help: stackoverflow.com/questions/734309/haskell-ide-for-windows Oct 21, 2011 at 21:25
  • I've copied this code to program with csort and renamed it. And I've got two errors now - couldn't match expected type Bool for 3rd string and the same error for 4th Oct 21, 2011 at 21:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.