[Haskell-cafe] Re: Processing of large files
t.zielonka at students.mimuw.edu.pl
Thu Nov 4 03:40:25 EST 2004
On Thu, Nov 04, 2004 at 09:24:30AM +0100, Ketil Malde wrote:
> Tomasz Zielonka <t.zielonka at students.mimuw.edu.pl> writes:
> >> Thank you. It works for me too, but I don't understand why and how ;-))
> >> Could you explain?
> I'm a bit puzzled by this discussion, as strictness of FiniteMaps have
> rarely been (perceived to be?) a problem for me.
It was a problem for me. Perhaps not too often, but it was.
> If you insert a value into a FiniteMap, isn't the key necessarily
> evaluated anyway?
Yes, but the problem was in values, not keys.
> Or is the problem that you can get a long chain of unevaluated
> 'addToFM's? The trick would then be to evaluate the FM now and then
> (e.g. using a strict fold).
Yes, you can do that. But sometimes it is quite inconvenient, and can
change O(log N) insert time to amortized O(log N) time. If you evalute
the FM too often, you can even change it to Theta(N).
> I thought simply forcing evaluation of the value before inserting
> would do it (i.e. something like
> v `seq` addToFm fm k v
Sure, but we were talking about addToFM_C.
> Am I missing something?
.signature: Too many levels of symbolic links
More information about the Haskell-Cafe