[Chicago-talk] neat little optimization

Komtanoo Pinpimai komtanoo at gmail.com
Wed Oct 13 21:24:34 CDT 2004


I think I had seen someone mentioned that the memoization will be
embeded in Perl6, called fly weight pattern.

In the fly weight pattern when you call a function, the compiler
record you function call and all the operators.

When the function is invoked with the same parameters, the compiler
will return the last calculation immediately. So you can solve
fibinacci series or dynamic programming problems with a naive
recusion.

This is amazing, but make programmer more lazy.


On Wed, 13 Oct 2004 14:21:22 -0400, Steven Lembark <lembark at wrkhors.com> wrote:
> 
> >      $cached{$self} += shift;
> 
> You might also save time using
> 
>         exists $cached{$item}
> 
> instead of checking the value: saves you from actually having
> to retrieve any data from the hash.
> 
> 
> 
> 
> --
> Steven Lembark                                       85-09 90th Street
> Workhorse Computing                                Woodhaven, NY 11421
> lembark at wrkhors.com                                     1 888 359 3508
> _______________________________________________
> Chicago-talk mailing list
> Chicago-talk at mail.pm.org
> http://mail.pm.org/mailman/listinfo/chicago-talk
>


More information about the Chicago-talk mailing list