[Haskell-cafe] Finding the average in constant space

Eugene Kirpichov ekirpichov at gmail.com
Sun May 27 10:21:08 CEST 2012


A lot of people have done this :) eg from me: google up a fairly recent thread from me about processing streams and perhaps the keyword "timeplot" (writing from a dying phone, can't do myself)



27.05.2012, в 12:04, Chris Wong <chrisyco+haskell-cafe at gmail.com> написал(а):

> Hello all
> 
> I just came up with a way of executing multiple folds in a single
> pass. In short, we can write code like this:
> 
>   average = foldLeft $ (/) <$> sumF <*> lengthF
> 
> and it will only traverse the input list once.
> 
> The code is at: https://gist.github.com/2802644
> 
> My question is: has anyone done this already? If not, I might release
> this on Hackage -- it seems quite useful.
> 
> Chris
> 
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe



More information about the Haskell-Cafe mailing list