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. Commented 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.

Sign up to request clarification or add additional context in comments.

6 Comments

But they are intended equally. it's only here they are not equal
you must have a tab character somewhere, because when they are not indented equally, that is the exact error I receive.
@Артём Царионов - 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.
@Артём Царионов 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
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
|

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.