Put 3digit-groups into its own vocabulary

db4
Samuel Tardieu 2009-01-23 15:22:03 +01:00
parent 6e9f0dbfdd
commit fc384c433b
6 changed files with 20 additions and 5 deletions

View File

@ -1,7 +1,7 @@
! Copyright (c) 2007, 2008 Aaron Schaefer.
! See http://factorcode.org/license.txt for BSD license.
USING: combinators.short-circuit grouping kernel math math.parser namespaces
sequences ;
USING: combinators.short-circuit grouping kernel math math.parser
math.text.utils namespaces sequences ;
IN: math.text.english
<PRIVATE
@ -31,9 +31,6 @@ SYMBOL: and-needed?
: negative-text ( n -- str )
0 < "Negative " "" ? ;
: 3digit-groups ( n -- seq )
[ dup 0 > ] [ 1000 /mod ] [ ] produce nip ;
: hundreds-place ( n -- str )
100 /mod over 0 = [
2drop ""

View File

@ -0,0 +1 @@
Aaron Schaefer

View File

@ -0,0 +1 @@
Number to text conversion utilities

View File

@ -0,0 +1,6 @@
USING: help.markup help.syntax ;
IN: math.text.utils
HELP: 3digit-groups
{ $values { "n" "a positive integer" } { "seq" "a sequence" } }
{ $description "Decompose a number into 3 digits groups and return them in a sequence, starting with the units, then the tenths, etc." } ;

View File

@ -0,0 +1,3 @@
USING: math.text.utils tools.test ;
[ { 1 999 2 } ] [ 2999001 3digit-groups ] unit-test

View File

@ -0,0 +1,7 @@
! Copyright (c) 2007, 2008 Aaron Schaefer.
! See http://factorcode.org/license.txt for BSD license.
USING: kernel math sequences ;
IN: math.text.utils
: 3digit-groups ( n -- seq )
[ dup 0 > ] [ 1000 /mod ] [ ] produce nip ;