Put 3digit-groups into its own vocabulary
parent
6e9f0dbfdd
commit
fc384c433b
|
@ -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 ""
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Aaron Schaefer
|
|
@ -0,0 +1 @@
|
|||
Number to text conversion utilities
|
|
@ -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." } ;
|
|
@ -0,0 +1,3 @@
|
|||
USING: math.text.utils tools.test ;
|
||||
|
||||
[ { 1 999 2 } ] [ 2999001 3digit-groups ] unit-test
|
|
@ -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 ;
|
Loading…
Reference in New Issue