Permalink
Browse files

Implement ADD, MULTIPLY and POWER for natural numbers

  • Loading branch information...
tomstuart committed Oct 17, 2011
1 parent 29e4596 commit 3bf39f9c9913ad568cbdae075966cc9c4dd25984
Showing with 6 additions and 6 deletions.
  1. +3 −3 lib/nothing.rb
  2. +3 −3 spec/nothing_spec.rb
View
@@ -9,9 +9,9 @@ module Nothing
TIMES = -> n { -> f { -> x { n[f][x] } } }
INCREMENT = -> n { -> f { -> x { f[n[f][x]] } } }
# ADD =
# MULTIPLY =
# POWER =
ADD = -> m { -> n { n[INCREMENT][m] } }
MULTIPLY = -> m { -> n { n[ADD[m]][ZERO] } }
POWER = -> m { -> n { n[MULTIPLY[m]][ONE] } }
# DECREMENT =
# SUBTRACT =
View
@@ -11,9 +11,9 @@
specify { TIMES[representation_of 3][-> s { s + 'o' }]['hell'].should == 'hellooo' }
specify { INCREMENT[representation_of 2].should represent 2 + 1 }
specify { pending { ADD[representation_of 2][representation_of 3].should represent 2 + 3 } }
specify { pending { MULTIPLY[representation_of 2][representation_of 3].should represent 2 * 3 } }
specify { pending { POWER[representation_of 2][representation_of 3].should represent 2 ** 3 } }
specify { ADD[representation_of 2][representation_of 3].should represent 2 + 3 }
specify { MULTIPLY[representation_of 2][representation_of 3].should represent 2 * 3 }
specify { POWER[representation_of 2][representation_of 3].should represent 2 ** 3 }
specify { pending { DECREMENT[representation_of 3].should represent 3 - 1 } }
specify { pending { SUBTRACT[representation_of 3][representation_of 2].should represent 3 - 2 } }

0 comments on commit 3bf39f9

Please sign in to comment.