Gwern Branwen wrote:
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA512
On Tue, Jan 20, 2009 at 7:22 PM, NeonGraal wrote:
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
iEYEAREKAAYFAkl2bTwACgkQvpDo5Pfl1oJPmACfaAbslKFWIXm2PVDC23ezXwcA
vWkAnjK+6Rj0WYvjTDLllgcxasoF+rUc
=Hrf0
Dean's version certainly seems the neatest, but just for interest you
can also do it with a cps fold instead of foldl' too:
table xs = assocs $! cpsfold f empty xs
where
f x m k = case Map.lookup x m of
Just v -> v `seq` (k $ Map.adjust (+1) x m)
Nothing ->
ike an enhanced version of the current web. But
Haskell could get involved there too, especially if styles such as web
programming with continuations prove useful in future generations of web
services architectures.
Amanda
--
Amanda Clare http://users.aber.ac.uk/afc/
Dept. of Computer Science, Univ
1) Is there a more efficient definition of hyperseq that does not traverse
the data structure twice? The "show" function traverses the structure once
but I found it to be much slower.
I think DeepSeq is what you're looking for. I've had all these problems
and more and written down the advice peop
How can I recursively collect a list of things while in the IO monad,
and return the list lazily as it's constructed rather than waiting until
they've all been collected?
Perhaps an example will make things clearer:
main =
do xs <- getStrings
putStrLn (head xs)
getStrings =
do x <- g
[cpsfold omitted]
> Actually, and quite apart from it being cumbersome to use, I've got
> my doubts about whether this cpsfold really does the job (is that
> just me missing some point?-).
It does the job for me! In practical terms I can see it works. I'm not
an expert - I may have this all wro
cpsfold f a (x:xs) = f x a (\y -> cpsfold f y xs)
and f takes a continuation, Bob's my uncle, and I have a program that
runs quickly in constant space!
Amanda
--
Amanda Clare http://users.aber.ac.uk/ajc99/
Tel: +44 (0)1970 621787 Fax: +44 (0)1970 622455
Dept. of Computer Science,
Apologies for the typo: that should have been 5 elements, not 500.
Amanda Clare wrote:
> I have stack problems: my program uses too much stack. I suspect, from
> removing bits of code, that it's due to a foldr in my program. If I use
> foldr or foldl on a long list (eg >5
on
the stack? If so, is there an obvious refactoring of the fold to use?
Amanda
--
Amanda Clare http://users.aber.ac.uk/ajc99/
Tel: +44 (0)1970 621787 Fax: +44 (0)1970 622455
Dept. of Computer Science, University of Wales, Aberystwyth, SY23 3DB
___
ation deeply enough. See
> http://haskell.org/pipermail/haskell/2001-August/001581.html and followup
> article.
Thanks, that's just what I need. It works! Perhaps if this is becoming a
frequently asked question, there should be a mention of this problem in
the Haskell report where seq is
uot;seq") have no effect
here? Is there a better way to do this?
Amanda
--
Amanda Clare http://users.aber.ac.uk/ajc99/
Tel: +44 (0)1970 621922 Fax: +44 (0)1970 622455
Dept. of Computer Science, University of Wales, Aberystwyth, SY23 3DB
___
Hask
11 matches
Mail list logo