On Fri, Oct 17, 2008 at 6:21 AM, leledumbo <[EMAIL PROTECTED]>wrote:
>
> So, what's the solution? This one:
>
> (l::[Ord]) <- readLn
>
> doesn't work (because Ord isn't a type constructor). It doesn't even comply
> to Haskell 98 standard. I want to be able to read any list of ordered
> elements.
I can't think of a language that lets you do this; that is, allow you
to input a list of any type as text.
Some languages effectively encode the types in the parsing, for
example in LISP, you know that 'foo is a symbol. It has a very
limited set of data types and new types are described entirely
On Fri, Oct 17, 2008 at 2:21 PM, leledumbo <[EMAIL PROTECTED]> wrote:
>
> So, what's the solution? This one:
>
> (l::[Ord]) <- readLn
>
> doesn't work (because Ord isn't a type constructor). It doesn't even comply
> to Haskell 98 standard. I want to be able to read any list of ordered
> elements.
On Fri, Oct 17, 2008 at 7:21 AM, leledumbo <[EMAIL PROTECTED]> wrote:
>
> So, what's the solution? This one:
>
> (l::[Ord]) <- readLn
>
> doesn't work (because Ord isn't a type constructor). It doesn't even comply
> to Haskell 98 standard. I want to be able to read any list of ordered
> elements.
So, what's the solution? This one:
(l::[Ord]) <- readLn
doesn't work (because Ord isn't a type constructor). It doesn't even comply
to Haskell 98 standard. I want to be able to read any list of ordered
elements.
--
View this message in context:
http://www.nabble.com/List-as-input-tp19987726p2
On 2008 Oct 16, at 22:22, leledumbo wrote:
... If there isn't enough information to set a concrete type at
the call,
type inference fails. This is what you get with strong typing.
In my case, where does type inference fail? Strong typing is good,
but quite
confusing when combined with poly
> How about a list of functions from int to int?
Hmm... it does make sense.
--
View this message in context:
http://www.nabble.com/List-as-input-tp19987726p20026222.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.
___
Has
On Thu, Oct 16, 2008 at 7:22 PM, leledumbo <[EMAIL PROTECTED]>wrote:
>
> > ... If there isn't enough information to set a concrete type at the
> call,
> type inference fails. This is what you get with strong typing.
>
> In my case, where does type inference fail? Strong typing is good, but
> quit
> ... If there isn't enough information to set a concrete type at the call,
type inference fails. This is what you get with strong typing.
In my case, where does type inference fail? Strong typing is good, but quite
confusing when combined with polymorphism.
> It isn't. The type of data in the
On Wed, Oct 15, 2008 at 9:53 PM, leledumbo <[EMAIL PROTECTED]>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
On 2008 Oct 16, at 0:53, leledumbo 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?
A function may have a polymorphic type; this allows its actual ty
> 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?
> I'm curious as to why taking the pivot from the middle is an
'optimized' version.
Consider if it's used in a
On Thu, Oct 16, 2008 at 9:01 AM, Dan Weston <[EMAIL PROTECTED]> wrote:
> Google "median order statistic".
>
> E.g. this is an interesting (and colorful) discussion:
>
> http://ocw.mit.edu/NR/rdonlyres/Electrical-Engineering-and-Computer-Science/6-046JFall-2005/60D030CD-081D-4192-9FB5-C220116E280D/0
Google "median order statistic".
E.g. this is an interesting (and colorful) discussion:
http://ocw.mit.edu/NR/rdonlyres/Electrical-Engineering-and-Computer-Science/6-046JFall-2005/60D030CD-081D-4192-9FB5-C220116E280D/0/lec6.pdf
Toby Hutton wrote:
On Wed, Oct 15, 2008 at 5:44 PM, leledumbo <[EM
On Wed, Oct 15, 2008 at 5:44 PM, leledumbo <[EMAIL PROTECTED]> wrote:
>
> module Main where
>
> import Data.List
>
> -- quicksort of any list
> qsort [] = []
> qsort (x:xs) = qsort(filter(=x) xs)
>
> -- optimized quicksort, uses middle element as pivot
> qsortOpt [] = []
> qsortOpt x = qsortOp
leledumbo wrote:
module Main where
import Data.List
-- quicksort of any list
qsort [] = []
qsort (x:xs) = qsort(filter(=x) xs)
-- optimized quicksort, uses middle element as pivot
qsortOpt [] = []
qsortOpt x = qsortOpt less ++ [pivot] ++ qsortOpt greater
where
pivot = x !! ((length
module Main where
import Data.List
-- quicksort of any list
qsort [] = []
qsort (x:xs) = qsort(filter(=x) xs)
-- optimized quicksort, uses middle element as pivot
qsortOpt [] = []
qsortOpt x = qsortOpt less ++ [pivot] ++ qsortOpt greater
where
pivot = x !! ((length x) `div` 2)
le
17 matches
Mail list logo