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:
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.
What
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.
I hope to
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 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.
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 the
... 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 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
quite
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.
___
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
leledumbo wrote:
module Main where
import Data.List
-- quicksort of any list
qsort [] = []
qsort (x:xs) = qsort(filter(x) xs) ++ [x] ++ qsort(filter(=x) xs)
-- optimized quicksort, uses middle element as pivot
qsortOpt [] = []
qsortOpt x = qsortOpt less ++ [pivot] ++ qsortOpt greater
module Main where
import Data.List
-- quicksort of any list
qsort [] = []
qsort (x:xs) = qsort(filter(x) xs) ++ [x] ++ qsort(filter(=x) xs)
-- optimized quicksort, uses middle element as pivot
qsortOpt [] = []
qsortOpt x = qsortOpt less ++ [pivot] ++ qsortOpt greater
where
pivot = x
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) ++ [x] ++ qsort(filter(=x) xs)
-- optimized quicksort, uses middle element as pivot
qsortOpt [] = []
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
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:
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 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
17 matches
Mail list logo