factor: DECIMAL: -> decimal:, ROMAN: -> roman:

char-rename
Doug Coleman 2017-06-04 15:57:26 -05:00
parent 9aacb29667
commit 1fa0f4100c
13 changed files with 64 additions and 64 deletions

View File

@ -92,11 +92,11 @@ HELP: roman/mod
{ roman* roman/i roman/mod } related-words
HELP: ROMAN:
HELP: roman:
{ $description "A parsing word that reads the next token and converts it to an integer." }
{ $examples
{ $example "USING: prettyprint roman ;"
"ROMAN: v ."
"roman: v ."
"5"
}
} ;
@ -104,7 +104,7 @@ HELP: ROMAN:
ARTICLE: "roman" "Roman numerals"
"The " { $vocab-link "roman" } " vocabulary can convert numbers to and from the Roman numeral system and can perform arithmetic given Roman numerals as input." $nl
"A parsing word for literal Roman numerals:"
{ $subsections POSTPONE: ROMAN: }
{ $subsections POSTPONE: roman: }
"Converting to Roman numerals:"
{ $subsections
>roman

View File

@ -37,7 +37,7 @@ USING: arrays kernel math roman roman.private sequences tools.test ;
{ "i" "ii" } [ "v" "iii" roman/mod ] unit-test
[ "iii" "iii" roman- ] must-fail
{ 30 } [ ROMAN: xxx ] unit-test
{ 30 } [ roman: xxx ] unit-test
[ roman+ ] must-infer
[ roman- ] must-infer

View File

@ -69,4 +69,4 @@ ROMAN-OP: * ( x y -- z )
ROMAN-OP: /i ( x y -- z )
ROMAN-OP: /mod ( x y -- z w )
SYNTAX: ROMAN: scan-token roman> suffix! ;
SYNTAX: roman: scan-token roman> suffix! ;

View File

@ -5,11 +5,11 @@ sequences ;
IN: benchmark.e-decimals
: D-factorial ( n -- D! )
<iota> DECIMAL: 1 [ 0 <decimal> DECIMAL: 1 D+ D* ] reduce ; inline
<iota> decimal: 1 [ 0 <decimal> decimal: 1 D+ D* ] reduce ; inline
:: calculate-e-decimals ( n -- e )
n [1,b] DECIMAL: 1
[ D-factorial DECIMAL: 1 swap n D/ D+ ] reduce ;
n [1,b] decimal: 1
[ D-factorial decimal: 1 swap n D/ D+ ] reduce ;
: e-decimals-benchmark ( -- )
5 [ 800 calculate-e-decimals drop ] times ;

View File

@ -5,7 +5,7 @@ locals math math.functions math.order random tools.test ;
IN: decimals.tests
{ t } [
DECIMAL: 12.34 DECIMAL: 00012.34000 =
decimal: 12.34 decimal: 00012.34000 =
] unit-test
: random-test-int ( -- n )
@ -37,15 +37,15 @@ ERROR: decimal-test-failure D1 D2 quot ;
] unit-test
{ t } [
{ DECIMAL: 0. DECIMAL: .0 DECIMAL: 0.0 DECIMAL: 00.00 DECIMAL: . } all-equal?
{ decimal: 0. decimal: .0 decimal: 0.0 decimal: 00.00 decimal: . } all-equal?
] unit-test
{ t } [ T{ decimal f 90 0 } T{ decimal f 9 1 } = ] unit-test
{ t } [ DECIMAL: 1 DECIMAL: 2 before? ] unit-test
{ f } [ DECIMAL: 2 DECIMAL: 2 before? ] unit-test
{ f } [ DECIMAL: 3 DECIMAL: 2 before? ] unit-test
{ f } [ DECIMAL: -1 DECIMAL: -2 before? ] unit-test
{ f } [ DECIMAL: -2 DECIMAL: -2 before? ] unit-test
{ t } [ DECIMAL: -3 DECIMAL: -2 before? ] unit-test
{ t } [ DECIMAL: .5 DECIMAL: 0 DECIMAL: 1.0 between? ] unit-test
{ t } [ decimal: 1 decimal: 2 before? ] unit-test
{ f } [ decimal: 2 decimal: 2 before? ] unit-test
{ f } [ decimal: 3 decimal: 2 before? ] unit-test
{ f } [ decimal: -1 decimal: -2 before? ] unit-test
{ f } [ decimal: -2 decimal: -2 before? ] unit-test
{ t } [ decimal: -3 decimal: -2 before? ] unit-test
{ t } [ decimal: .5 decimal: 0 decimal: 1.0 between? ] unit-test

View File

@ -19,7 +19,7 @@ C: <decimal> decimal
: parse-decimal ( -- decimal ) scan-token string>decimal ;
SYNTAX: DECIMAL: parse-decimal suffix! ;
SYNTAX: decimal: parse-decimal suffix! ;
: decimal>ratio ( decimal -- ratio ) >decimal< 10^ * ;

View File

@ -1,28 +1,28 @@
USING: money parser tools.test eval ;
IN: money.tests
{ -1/10 } [ DECIMAL: -.1 ] unit-test
{ -1/10 } [ DECIMAL: -0.1 ] unit-test
{ -1/10 } [ DECIMAL: -00.10 ] unit-test
{ -1/10 } [ decimal: -.1 ] unit-test
{ -1/10 } [ decimal: -0.1 ] unit-test
{ -1/10 } [ decimal: -00.10 ] unit-test
{ 0 } [ DECIMAL: .0 ] unit-test
{ 0 } [ DECIMAL: 0.0 ] unit-test
{ 0 } [ DECIMAL: 0. ] unit-test
{ 0 } [ DECIMAL: 0 ] unit-test
{ 1/10 } [ DECIMAL: .1 ] unit-test
{ 1/10 } [ DECIMAL: 0.1 ] unit-test
{ 1/10 } [ DECIMAL: 00.10 ] unit-test
{ 23 } [ DECIMAL: 23 ] unit-test
{ -23 } [ DECIMAL: -23 ] unit-test
{ -23-1/100 } [ DECIMAL: -23.01 ] unit-test
{ 0 } [ decimal: .0 ] unit-test
{ 0 } [ decimal: 0.0 ] unit-test
{ 0 } [ decimal: 0. ] unit-test
{ 0 } [ decimal: 0 ] unit-test
{ 1/10 } [ decimal: .1 ] unit-test
{ 1/10 } [ decimal: 0.1 ] unit-test
{ 1/10 } [ decimal: 00.10 ] unit-test
{ 23 } [ decimal: 23 ] unit-test
{ -23 } [ decimal: -23 ] unit-test
{ -23-1/100 } [ decimal: -23.01 ] unit-test
[ "DECIMAL: ." eval ] must-fail
[ "DECIMAL: f" eval ] must-fail
[ "DECIMAL: 0.f" eval ] must-fail
[ "DECIMAL: f.0" eval ] must-fail
[ "decimal: ." eval ] must-fail
[ "decimal: f" eval ] must-fail
[ "decimal: 0.f" eval ] must-fail
[ "decimal: f.0" eval ] must-fail
{ "$100.00" } [ DECIMAL: 100.0 money>string ] unit-test
{ "$0.00" } [ DECIMAL: 0.0 money>string ] unit-test
{ "$100.00" } [ decimal: 100.0 money>string ] unit-test
{ "$0.00" } [ decimal: 0.0 money>string ] unit-test
{ "$1.00" } [ 1.0 money>string ] unit-test
{ "$1.00" } [ 1 money>string ] unit-test

View File

@ -31,4 +31,4 @@ ERROR: not-an-integer x ;
[ dup string>number [ ] [ not-an-integer ] ?if ] bi@
] keep length 10^ / + swap [ neg ] when ;
SYNTAX: DECIMAL: scan-token parse-decimal suffix! ;
SYNTAX: decimal: scan-token parse-decimal suffix! ;

View File

@ -10,24 +10,24 @@ IN: taxes.usa.federal
: federal-single ( -- triples )
{
{ 0 2650 DECIMAL: 0 }
{ 2650 10300 DECIMAL: .10 }
{ 10300 33960 DECIMAL: .15 }
{ 33960 79725 DECIMAL: .25 }
{ 79725 166500 DECIMAL: .28 }
{ 166500 359650 DECIMAL: .33 }
{ 359650 1/0. DECIMAL: .35 }
{ 0 2650 decimal: 0 }
{ 2650 10300 decimal: .10 }
{ 10300 33960 decimal: .15 }
{ 33960 79725 decimal: .25 }
{ 79725 166500 decimal: .28 }
{ 166500 359650 decimal: .33 }
{ 359650 1/0. decimal: .35 }
} ;
: federal-married ( -- triples )
{
{ 0 8000 DECIMAL: 0 }
{ 8000 23550 DECIMAL: .10 }
{ 23550 72150 DECIMAL: .15 }
{ 72150 137850 DECIMAL: .25 }
{ 137850 207700 DECIMAL: .28 }
{ 207700 365100 DECIMAL: .33 }
{ 365100 1/0. DECIMAL: .35 }
{ 0 8000 decimal: 0 }
{ 8000 23550 decimal: .10 }
{ 23550 72150 decimal: .15 }
{ 72150 137850 decimal: .25 }
{ 137850 207700 decimal: .28 }
{ 207700 365100 decimal: .33 }
{ 365100 1/0. decimal: .35 }
} ;
SINGLETON: federal

View File

@ -3,7 +3,7 @@
USING: accessors math math.order money kernel assocs ;
IN: taxes.usa.fica
: fica-tax-rate ( -- x ) DECIMAL: .062 ; inline
: fica-tax-rate ( -- x ) decimal: .062 ; inline
ERROR: fica-base-unknown ;

View File

@ -5,9 +5,9 @@ namespaces sequences money math.order ;
IN: taxes.usa.futa
! Employer tax only, not withheld
: futa-tax-rate ( -- x ) DECIMAL: .062 ; inline
: futa-tax-rate ( -- x ) decimal: .062 ; inline
: futa-base-rate ( -- x ) 7000 ; inline
: futa-tax-offset-credit ( -- x ) DECIMAL: .054 ; inline
: futa-tax-offset-credit ( -- x ) decimal: .054 ; inline
: futa-tax ( salary w4 -- x )
drop futa-base-rate min

View File

@ -4,5 +4,5 @@ USING: kernel math money ;
IN: taxes.usa.medicare
! No base rate for medicare; all wages subject
: medicare-tax-rate ( -- x ) DECIMAL: .0145 ; inline
: medicare-tax-rate ( -- x ) decimal: .0145 ; inline
: medicare-tax ( salary w4 -- x ) drop medicare-tax-rate * ;

View File

@ -8,18 +8,18 @@ IN: taxes.usa.mn
! Minnesota
: mn-single ( -- triples )
{
{ 0 1950 DECIMAL: 0 }
{ 1950 23750 DECIMAL: .0535 }
{ 23750 73540 DECIMAL: .0705 }
{ 73540 1/0. DECIMAL: .0785 }
{ 0 1950 decimal: 0 }
{ 1950 23750 decimal: .0535 }
{ 23750 73540 decimal: .0705 }
{ 73540 1/0. decimal: .0785 }
} ;
: mn-married ( -- triples )
{
{ 0 7400 DECIMAL: 0 }
{ 7400 39260 DECIMAL: .0535 }
{ 39260 133980 DECIMAL: .0705 }
{ 133980 1/0. DECIMAL: .0785 }
{ 0 7400 decimal: 0 }
{ 7400 39260 decimal: .0535 }
{ 39260 133980 decimal: .0705 }
{ 133980 1/0. decimal: .0785 }
} ;
: <mn> ( -- obj )