[Haskell-cafe] List as input

David Leimbach leimy2k at gmail.com
Thu Oct 16 09:29:57 EDT 2008

On Wed, Oct 15, 2008 at 9:53 PM, leledumbo <leledumbo_cool at yahoo.co.id>wrote:

> > The compiler doesn't know what kind of list you are trying to read,
> sort, and print.
> So, the type must be specific? Then why it's possible to call the sorting
> function with any list?

It isn't.  The type of data in the list must be able to be compared.

See the type signature for Data.List.sort

Data.List.sort :: (Ord a) => [a] -> [a]

So "any" list may be sorted if the items in the list are of Ord.

> > I'm curious as to why taking the pivot from the middle is an
> 'optimized' version.
> Consider if it's used in a GUI program which calls the function when a
> button is pressed. Often, users clicks the button more than once. If the
> pivot is the first (or last) element, the second (and further) click will
> cause worst case scenario to happen. OTOH, if the pivot is the middle
> element, best case scenario will happen.

> --
> View this message in context:
> http://www.nabble.com/List-as-input-tp19987726p20007078.html
> Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081016/94e1a45e/attachment-0001.htm

More information about the Haskell-Cafe mailing list