Merge branch 'master' of git://projects.elasticdog.com/git/factor

db4
Slava Pestov 2008-12-15 22:55:59 -06:00
commit fea0c80542
2 changed files with 12 additions and 12 deletions

View File

@ -1,4 +1,5 @@
USING: definitions help help.markup help.syntax io io.files editors words ; USING: definitions editors help help.markup help.syntax io io.files
io.pathnames words ;
IN: editors.vim IN: editors.vim
ARTICLE: { "vim" "vim" } "Vim support" ARTICLE: { "vim" "vim" } "Vim support"

View File

@ -32,23 +32,22 @@ SYMBOL: and-needed?
0 < "Negative " "" ? ; 0 < "Negative " "" ? ;
: 3digit-groups ( n -- seq ) : 3digit-groups ( n -- seq )
number>string <reversed> 3 <groups> [ dup 0 > ] [ 1000 /mod ] [ ] produce nip ;
[ reverse string>number ] map ;
: hundreds-place ( n -- str ) : hundreds-place ( n -- str )
100 /mod swap dup zero? [ 100 /mod over 0 = [
2drop "" 2drop ""
] [ ] [
small-numbers " Hundred" append [ small-numbers " Hundred" append ] dip
swap zero? [ " and " append ] unless 0 = [ " and " append ] unless
] if ; ] if ;
: tens-place ( n -- str ) : tens-place ( n -- str )
100 mod dup 20 >= [ 100 mod dup 20 >= [
10 /mod [ tens ] dip 10 /mod [ tens ] dip
dup zero? [ drop ] [ "-" swap small-numbers 3append ] if dup 0 = [ drop ] [ small-numbers "-" glue ] if
] [ ] [
dup zero? [ drop "" ] [ small-numbers ] if dup 0 = [ drop "" ] [ small-numbers ] if
] if ; ] if ;
: 3digits>text ( n -- str ) : 3digits>text ( n -- str )
@ -59,15 +58,15 @@ SYMBOL: and-needed?
[ " " glue ] unless-empty ; [ " " glue ] unless-empty ;
: append-with-conjunction ( str1 str2 -- newstr ) : append-with-conjunction ( str1 str2 -- newstr )
over length zero? [ over length 0 = [
nip nip
] [ ] [
and-needed? get " and " ", " ? rot 3append swap and-needed? get " and " ", " ?
and-needed? off glue and-needed? off
] if ; ] if ;
: (recombine) ( str index seq -- newstr ) : (recombine) ( str index seq -- newstr )
2dup nth zero? [ 2dup nth 0 = [
2drop 2drop
] [ ] [
text-with-scale append-with-conjunction text-with-scale append-with-conjunction