On Wed, May 14, 2008 at 06:08:28PM +0100, Paul Johnson wrote:
> We've had a big debate over
>
> > mean xs = foldl' (+) 0 xs / fromIntegral (length xs)
>
> For anyone who didn't follow it, the problem is that "mean" needs to
> traverse its argument twice, so the entire list has to be held in
> m
Luke Palmer wrote:
On Thu, May 15, 2008 at 8:45 PM, Andrew Coppin
<[EMAIL PROTECTED]> wrote:
Yitzchak Gale wrote:
And of course, you wouldn't want that:
f xs = xs : map expensiveCalculation xs
Please don't fuse those two loops into one.
...doesn't type check. Did you mean (++
On Thu, May 15, 2008 at 8:45 PM, Andrew Coppin
<[EMAIL PROTECTED]> wrote:
> Yitzchak Gale wrote:
>>
>>
>> And of course, you wouldn't want that:
>>
>> f xs = xs : map expensiveCalculation xs
>>
>> Please don't fuse those two loops into one.
>>
>
> ...doesn't type check. Did you mean (++)?
Hmm? Wh
Yitzchak Gale wrote:
And of course, you wouldn't want that:
f xs = xs : map expensiveCalculation xs
Please don't fuse those two loops into one.
...doesn't type check. Did you mean (++)?
In the case of "mean", the outer function in question
is /, and that is a good candidate for fusion
Don Stewart wrote:
> You'd want a general fusion framework for this...
> Stream fusion... at least does this for zips...
> but for an arbitrary 'f' instead of zip,
> seems harder.
And of course, you wouldn't want that:
f xs = xs : map expensiveCalculation xs
Please don't fuse those two loops int
Albert Y. C. Lai wrote:
If you worry that the sum thread and the length thread are not
synchronized and therefore there is still no bound on the list prefix
kept in memory, I'm sure you can improve it by one of the chunking
strategies.
I'm more worried that data now has to go through tiny CPU
Paul Johnson wrote:
The solution is for the programmer to rewrite "mean" to accumulate a
pair containing the running total and count together, then do the
division. This makes me wonder: could there be a compiler optimisation
rule for this, collapsing two iterations over a list into one.
Do
Don Stewart wrote:
You'd want a general fusion framework for this, and other accumulators,
that's let's you treat 'f' as a zip of some kind that pulls items from
its two arguments. And then require only a single rewrite rule for all
your loop forms.
Stream fusion (see "Lists to Streams to Nothin
On Wed, 14 May 2008, Paul Johnson wrote:
We've had a big debate over
mean xs = foldl' (+) 0 xs / fromIntegral (length xs)
For anyone who didn't follow it, the problem is that "mean" needs to traverse
its argument twice, so the entire list has to be held in memory. So if "xs =
[1..100
paul:
> We've had a big debate over
>
> > mean xs = foldl' (+) 0 xs / fromIntegral (length xs)
>
> For anyone who didn't follow it, the problem is that "mean" needs to
> traverse its argument twice, so the entire list has to be held in
> memory. So if "xs = [1..10]" then "mean xs" uses
We've had a big debate over
> mean xs = foldl' (+) 0 xs / fromIntegral (length xs)
For anyone who didn't follow it, the problem is that "mean" needs to
traverse its argument twice, so the entire list has to be held in
memory. So if "xs = [1..10]" then "mean xs" uses all your
memory,
11 matches
Mail list logo