[Haskell-cafe] Efficiency/Evaluation Question
Tikhon Jelvis
tikhon at jelv.is
Sun Jun 16 03:52:05 CEST 2013
There's a very good StackOverflow question which covers this: "When is
memoization automatic in GHC?"[1]. I found it really cleared up the issue
for me.
[1]:
http://stackoverflow.com/questions/3951012/when-is-memoization-automatic-in-ghc-haskell
On Sat, Jun 15, 2013 at 9:13 PM, Clark Gaebel <cgaebel at uwaterloo.ca> wrote:
> Yes. In general, GHC won't CSE for you.
>
> - Clark
>
>
> On Saturday, June 15, 2013, Christopher Howard wrote:
>
>> On 06/15/2013 04:39 PM, Tommy Thorn wrote:
>> >
>> >
>> > There's not enough context to answer the specific question,
>> > but lazy evaluation isn't magic and the answer is probably "no".
>> >
>> > Tommy
>> >
>>
>> Perhaps to simplify the question somewhat with a simpler example.
>> Suppose you have
>>
>> code:
>> --------
>> let f x = if (x > 4) then f 0 else (sin x + 2 * cos x) : f (x + 1)
>> --------
>>
>> After calculating at x={0,1,2,3}, and the cycle repeats, are sin, cos,
>> etc. calculated anymore?
>>
>> --
>> frigidcode.com
>>
>>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20130615/72582df9/attachment.htm>
More information about the Haskell-Cafe
mailing list