RAA - memoize

memoize / 1.3.1

Short description: A method that speeds methods up at the cost of memory
Category: Library/Cache
Status: stable
Created: 2005-09-09 21:15:41 GMT
Last update: 2009-08-08 14:51:29 GMT
Owner: Daniel J. Berger (Projects of this owner)
Homepage: http://www.rubyforge.org/projects/shards
Download: http://rubyforge.org/frs/download.php/61790/memoize-1.3.1.tar.gz
License: Artistic
Dependency:
None
Description:
A method that speeds methods up at the cost of memory (or disk space).

require "memoize"
include Memoize

# Inefficient fibonacci method
def fib(n)
   return n if n < 2
   fib(n-1) + fib(n-2)
end

fib(100) # Slow

memoize(:fib)
fib(100) # Fast

memoize(:fib, "fib.cache")
fib(100) # Fast
Versions: [1.3.1 (2009-08-08)] [1.3.0 (2009-07-20)] [1.2.3 (2007-05-24)] [1.2.2 (2006-02-04)] [1.2.1 (2006-02-02)] [1.2.0 (2006-01-01)] [1.1.0 (2005-10-22)] [1.0.0 (2005-09-09)]

Edit this project (for project owner)

back to RAA top