sub memoize { my ($f_name) = @_; my $f_ref = get_reference($f_name); my %cache; my $new_f = sub { my $key = join ' ', @_; return $cache{$key} if exists $cache{$key}; $cache{$key} = $f_ref->(@_); }; # Now do some magic to replace function $f with $new_f } |
http://www.plover.com/~mjd/perl/MiniMemoize/ |
Forward to Users
Back to Memoize Up to section index Up to Using tie to escape feature creep course index |
Using tie to escape feature creep: - 3 Copyright © 2000 Mark-Jason Dominus |