Oops, everything I said had already been said elsewhere in the
discussion; I just hadn't read it all yet. Sorry for the waste of
bandwidth.
Matt Harden wrote:
<< a bunch of stuff that others had already said >>
Joe Fasel wrote:
>
> S.D.Mechveliani <[EMAIL PROTECTED]> writes
> | Marcin 'Qrczak' Kowalczyk <[EMAIL PROTECTED]> writes
> | > partition _ [] = ([], [])
> | > partition p (x:xs) = if p x then (x:ys, zs) else (ys, x:zs)
> | > where (ys, zs) = partition p xs
> | >
> | > runs your example
Folks,
I claimed that these are different functions:
> partition1 p xs = (filter p xs, filter (not . p) xs)
> partition2 p = foldr (\x (ys, zs) -> if p x then (x:ys,zs) else (ys,x:zs))
> ([],[])
I was correct, but not for the reason I thought. Nota bene:
partition1
Hi.
I'm 80% confident in this reply, and 99% confident that someone will
correct me if it's wrong or misleading. :-)
Eileen Head writes:
> Is there an easy way to define a new class, X, of types which is a
> class of some range of types in an existing class Y.
Yes, but only if the existing t
Duh! Please forgive my stupidity.
We were talking about this definition of partition:
> partition _ [] = ([], [])
> partition p (x:xs) = if p x then (x:ys, zs) else (ys, x:zs)
> where (ys, zs) = partition p xs
But all the time, I was thinking about this one:
> partition p xs = partit
Hi Keith,
| Type inference for Haskell (as described in Mark Jones' paper _Typing
| Haskell In Haskell_ and as performed by GHC) requires first splitting
| groups of let bindings into strongly-connected components. It then
| assumes that all binders in such a component will be generalised ove
Is there an easy way to define a new class, X, of types which is a class
of some range of types in an existing class Y.
For example can you define a class PosNum in which the type in the class
are positive Ints, positive Integers, positive Floats and positive
Doubles?
To
| > partition _ [] = ([], [])
| > partition p (x:xs) = if p x then (x:ys, zs) else (ys, x:zs)
| > where (ys, zs) = partition p xs
| >
| > runs your example in constant space.
Joe Fasel <[EMAIL PROTECTED]> writes
> This probably works fine for many applications, but of course,
> it
Type inference for Haskell (as described in Mark Jones' paper _Typing
Haskell In Haskell_ and as performed by GHC) requires first splitting
groups of let bindings into strongly-connected components. It then
assumes that all binders in such a component will be generalised over
the same vector
S.D.Mechveliani <[EMAIL PROTECTED]> writes
| Marcin 'Qrczak' Kowalczyk <[EMAIL PROTECTED]> writes
| > partition _ [] = ([], [])
| > partition p (x:xs) = if p x then (x:ys, zs) else (ys, x:zs)
| > where (ys, zs) = partition p xs
| >
| > runs your example in constant space.
|
|
| Proba
Marcin 'Qrczak' Kowalczyk <[EMAIL PROTECTED]> writes
> S.D.Mechveliani <[EMAIL PROTECTED]> pisze:
>> But "filter-filter" implementation needs a constant space for
>>
>> head $ fst $ partition (==1) [0..n].
>>
>> And some recent implementations take heap+stack proportio
11 matches
Mail list logo