On 12/01/2008, Hugh Perkins <[EMAIL PROTECTED]> wrote:
> On Jan 12, 2008 10:19 PM, Rafael Almeida <[EMAIL PROTECTED]> wrote:
> > After some profiling I found out that about 94% of the execution time is
> > spent in the ``isPerfectSquare'' function.
>
> I guess that Haskell's referential transparence means the answers to
> the isPerfectSquare will be cached, ie automatically memoized? (not
> sure if is correct term?)

This isn't true unless calling isPerfectSquare reads the result out of
a lazily generated array of responses or some other data structure at
the top-level. There's no memoisation of functions by default because
it would typically require ridiculous amounts of memory, however, you
can usually rely on values bound to variables to only be computed
once, barring those which are typeclass polymorphic.

 - Cale
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to