[email protected]
[Top] [All Lists]

Re: [Haskell-cafe] foldl in terms of foldr

Subject: Re: [Haskell-cafe] foldl in terms of foldr
From: Xingzhi Pan
Date: Wed, 27 Jan 2010 00:15:28 +0800
On Wed, Jan 27, 2010 at 12:05 AM, Eduard Sergeev
<[email protected]> wrote:
>
>
> Neil Brown-7 wrote:
>>
>> step is of type b -> (a -> a) -> (a -> a), which does agree with (a -> b
>> -> b)
>
> Not quite right..
> Let's rewite the function:
>
> myFoldl f z xs = foldr (step f) id xs z
> step f x g = \a -> g (f a x)

I am not very sure about this.  This rewriting was my first reaction
against the original code but it failed compilation with GHC.

More over, does "foldr step f id xs z" equal to "foldr (step f) id xs z"??

Thanks!

>
> now (from ghci):
> step (+) :: (Num t1) => t1 -> (t1 -> t3) -> t1 -> t3
>
> or even:
> step (flip (:)) :: t -> ([t] -> t3) -> [t] -> t3
>
> But yes, the type from my first post was wrong
>
> --
> View this message in context: 
> http://old.nabble.com/foldl-in-terms-of-foldr-tp27322307p27325072.html
> Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.
>
> _______________________________________________
> Haskell-Cafe mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>



-- 
Pan, Xingzhi
http://www.panxingzhi.net
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

<Prev in Thread] Current Thread [Next in Thread>