Skip to content
This repository has been archived by the owner on May 26, 2020. It is now read-only.

Fix markdown files embedding in documentation #22

Merged
merged 2 commits into from Feb 23, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion .yardopts
Expand Up @@ -6,7 +6,6 @@
--title=Functional Ruby
--template default

./doc/**/*.txt
./lib/**/*.rb
-
README.md
Expand Down
Empty file removed doc/.gitignore
Empty file.
26 changes: 13 additions & 13 deletions doc/memo.md
Expand Up @@ -10,11 +10,11 @@
[memoization](http://en.wikipedia.org/wiki/Memoization).

### Declaration

Using memoization requires two simple steps: including the
`Functional::Memo` module within a class or module and calling the `memoize`
function to enable memoization on one or more methods.

```ruby
Module EvenNumbers
include Functional::Memoize
Expand Down Expand Up @@ -46,7 +46,7 @@
the maximum size of the cache. Once the maximum cache size is reached, calls
to to the method with uncached args will still result in the method being
called, but the results will not be cached.

```ruby
Module EvenNumbers
include Functional::Memoize
Expand Down Expand Up @@ -119,34 +119,34 @@

```ruby
require 'functional'

class Factors
include Functional::Memo

def self.sum_of(number)
of(number).reduce(:+)
end

def self.of(number)
(1..number).select {|i| factor?(number, i)}
end

def self.factor?(number, potential)
number % potential == 0
end

def self.perfect?(number)
sum_of(number) == 2 * number
end

def self.abundant?(number)
sum_of(number) > 2 * number
end

def self.deficient?(number)
sum_of(number) < 2 * number
end

memoize(:sum_of)
memoize(:of)
end
Expand All @@ -155,10 +155,10 @@
This code was tested in IRB using MRI 2.1.2 on a MacBook Pro. The `sum_of`
method was called three times against the number 10,000,000 and the
benchmark results of each run were captured. The test code:

```ruby
require 'benchmark'

3.times do
stats = Benchmark.measure do
Factors.sum_of(10_000_000)
Expand Down