Hi,

Am Dienstag, den 04.10.2011, 09:39 +0300 schrieb Roman Cheplyaka:
> Suppose I want a foldl which is evaluated many times on the same
> list but with different folding functions.

I used this pattern successfully in SAT-Britney, where I generate a huge
list quite quickly, and I don’t want this list to stay in memory. I had
to pay a lot of attention to sharing, e.g. by making sure the parameters
to the function that generate the left fold are only passed when the
folding functions are also given, see in
http://git.nomeata.de/?p=sat-britney.git;a=commitdiff;h=e8a1eea156b76d76729a0ae55dbd7ac244f03470;hp=3bf044025665e3c7a925ca38cdcb945a103c9e6f
the changes to TransRules.hs. Otherwise, I’d get a huge thunk of
closures representing the list, as Jan-Willem predicted.

Note that I want to achieve something differently than you, unless I am
mistaken: In my case, I want to make sure the list can be fused or at
least immediately garbage-collected with every use, even if the code
that calculates the list has to be run multiple times.

Greetings,
Joachim

-- 
Joachim "nomeata" Breitner
  m...@joachim-breitner.de  |  nome...@debian.org  |  GPG: 0x4743206C
  xmpp: nome...@joachim-breitner.de | http://www.joachim-breitner.de/

Attachment: signature.asc
Description: This is a digitally signed message part

_______________________________________________
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

Reply via email to