[Haskell-cafe] Small optimisation question
Andrew Coppin
andrewcoppin at btinternet.com
Sat Nov 17 11:01:34 EST 2007
Suppose I write something like this:
foo :: [Int]
foo = concat (replicate 4 [4,7,2,9])
The value of "foo" is completely determined at compile-time. So, will
the compiler generate calls to concat and replicate, or will it just
insert a large list constant here?
Obviously, once somebody has completely examined the contents of "foo",
after that point it won't matter either way. I'm just curiose.
Concatinating some strings is cheap; I sometimes write constructs like
the above using much more expensive operations. (Expensive in time; the
space taken up by the result isn't that great.)
More information about the Haskell-Cafe
mailing list