inline the trivial words in math.parser

db4
Joe Groff 2009-10-22 17:26:22 -05:00
parent 27100ae094
commit 1a7b4d7c63
1 changed files with 15 additions and 15 deletions

View File

@ -111,10 +111,10 @@ SYMBOL: negative?
{ {
{ 16 [ hex>float ] } { 16 [ hex>float ] }
[ drop dec>float ] [ drop dec>float ]
} case ; } case ; inline
: number-char? ( char -- ? ) : number-char? ( char -- ? )
"0123456789ABCDEFabcdef." member? ; "0123456789ABCDEFabcdef." member? ; inline
: numeric-looking? ( str -- ? ) : numeric-looking? ( str -- ? )
"-" ?head drop "-" ?head drop
@ -127,7 +127,7 @@ SYMBOL: negative?
PRIVATE> PRIVATE>
: string>float ( str -- n/f ) : string>float ( str -- n/f )
10 base>float ; 10 base>float ; inline
: base> ( str radix -- n/f ) : base> ( str radix -- n/f )
over numeric-looking? [ over numeric-looking? [
@ -138,13 +138,13 @@ PRIVATE>
} case } case
] [ 2drop f ] if ; ] [ 2drop f ] if ;
: string>number ( str -- n/f ) 10 base> ; : string>number ( str -- n/f ) 10 base> ; inline
: bin> ( str -- n/f ) 2 base> ; : bin> ( str -- n/f ) 2 base> ; inline
: oct> ( str -- n/f ) 8 base> ; : oct> ( str -- n/f ) 8 base> ; inline
: hex> ( str -- n/f ) 16 base> ; : hex> ( str -- n/f ) 16 base> ; inline
: >digit ( n -- ch ) : >digit ( n -- ch )
dup 10 < [ CHAR: 0 + ] [ 10 - CHAR: a + ] if ; dup 10 < [ CHAR: 0 + ] [ 10 - CHAR: a + ] if ; inline
: positive>base ( num radix -- str ) : positive>base ( num radix -- str )
dup 1 <= [ "Invalid radix" throw ] when dup 1 <= [ "Invalid radix" throw ] when
@ -234,12 +234,12 @@ M: ratio >base
{ {
{ 16 [ float>hex ] } { 16 [ float>hex ] }
[ drop float>decimal ] [ drop float>decimal ]
} case ; } case ; inline
PRIVATE> PRIVATE>
: float>string ( n -- str ) : float>string ( n -- str )
10 float>base ; 10 float>base ; inline
M: float >base M: float >base
{ {
@ -251,9 +251,9 @@ M: float >base
[ float>base ] [ float>base ]
} cond ; } cond ;
: number>string ( n -- str ) 10 >base ; : number>string ( n -- str ) 10 >base ; inline
: >bin ( n -- str ) 2 >base ; : >bin ( n -- str ) 2 >base ; inline
: >oct ( n -- str ) 8 >base ; : >oct ( n -- str ) 8 >base ; inline
: >hex ( n -- str ) 16 >base ; : >hex ( n -- str ) 16 >base ; inline
: # ( n -- ) number>string % ; : # ( n -- ) number>string % ; inline