Skip to content

Commit

Permalink
Implement TO_STRING for natural numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
tomstuart committed Oct 28, 2011
1 parent 97ed146 commit 096db61
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/nothing.rb
Expand Up @@ -75,7 +75,8 @@ module Nothing
TEN = INCREMENT[MULTIPLY[THREE][THREE]]
RADIX = TEN
TO_DIGITS = Z[-> f { -> n { PUSH[IF[IS_LESS_OR_EQUAL[n][DECREMENT[RADIX]]][EMPTY][ -> _ { f[DIV[n][RADIX]][_] } ]][MOD[n][RADIX]] } }]
# TO_STRING =
TO_CHAR = -> n { n } # assume string encoding where 0 encodes '0', 1 encodes '1' etc
TO_STRING = -> n { MAP[TO_DIGITS[n]][TO_CHAR] }

# FizzBuzz

Expand Down
2 changes: 1 addition & 1 deletion spec/nothing_spec.rb
Expand Up @@ -41,7 +41,7 @@
end

context 'with strings' do
specify { pending { TO_STRING[representation_of 42].should represent '42' } }
specify { TO_STRING[representation_of 42].should represent '42' }
end
end

Expand Down

0 comments on commit 096db61

Please sign in to comment.