The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Memoize

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Premshree Pillai

Posts: 478
Nickname: premshree
Registered: Mar, 2004

Premshree Pillai is a Ruby evangelist, working with Yahoo!.
Memoize Posted: Jul 24, 2006 4:46 PM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Premshree Pillai.
Original Post: Memoize
Feed Title: Premshree's Personal Weblog
Feed URL: http://premshree.livejournal.com/data/rss
Feed Description: Premshree's Weblog
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Premshree Pillai
Latest Posts From Premshree's Personal Weblog

Advertisement

MJD was talking about Memoize. Here it is in Ruby:

module Memoize
  def memoize(func_name)
    cache = {}
    (class<<elf; self; end).send(:define_method, func_name) { |*args| 
      return cache[args] if cache.has_key? args
      cache[args] = super     
    }       
  end     
end

There’s a lot of code in the Perl Memoize module; maybe it does other things—I haven’t really looked. Oh, and here’s this Memoize module from RAA. I’m some months late. :-)

Here’s some pictures from Portland.

Read: Memoize

Topic: News From a Friend Previous Topic   Next Topic Topic: Rails HTML Caching Fun

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use