From c9e10e7b4afe2341a1f35c7e2ce393ffe61f91fe Mon Sep 17 00:00:00 2001 From: Aaron Schaefer Date: Mon, 15 Dec 2008 21:49:31 -0500 Subject: [PATCH 1/2] Update math.english with faster algorithm and new combinators --- extra/math/text/english/english.factor | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/extra/math/text/english/english.factor b/extra/math/text/english/english.factor index 41f19b9b07..643fc3ae05 100755 --- a/extra/math/text/english/english.factor +++ b/extra/math/text/english/english.factor @@ -32,23 +32,22 @@ SYMBOL: and-needed? 0 < "Negative " "" ? ; : 3digit-groups ( n -- seq ) - number>string 3 - [ reverse string>number ] map ; + [ dup 0 > ] [ 1000 /mod ] [ ] produce nip ; : hundreds-place ( n -- str ) - 100 /mod swap dup zero? [ + 100 /mod over 0 = [ 2drop "" ] [ - small-numbers " Hundred" append - swap zero? [ " and " append ] unless + [ small-numbers " Hundred" append ] dip + 0 = [ " and " append ] unless ] if ; : tens-place ( n -- str ) 100 mod dup 20 >= [ 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 ; : 3digits>text ( n -- str ) @@ -59,15 +58,15 @@ SYMBOL: and-needed? [ " " glue ] unless-empty ; : append-with-conjunction ( str1 str2 -- newstr ) - over length zero? [ + over length 0 = [ nip ] [ - and-needed? get " and " ", " ? rot 3append - and-needed? off + swap and-needed? get " and " ", " ? + glue and-needed? off ] if ; : (recombine) ( str index seq -- newstr ) - 2dup nth zero? [ + 2dup nth 0 = [ 2drop ] [ text-with-scale append-with-conjunction From 3b83db3a0682c983dea245efc461962d5756d00d Mon Sep 17 00:00:00 2001 From: Aaron Schaefer Date: Mon, 15 Dec 2008 21:50:10 -0500 Subject: [PATCH 2/2] Fix vim-docs.factor after moving around io words --- basis/editors/vim/vim-docs.factor | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/basis/editors/vim/vim-docs.factor b/basis/editors/vim/vim-docs.factor index cf42884084..3387dc5971 100644 --- a/basis/editors/vim/vim-docs.factor +++ b/basis/editors/vim/vim-docs.factor @@ -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 ARTICLE: { "vim" "vim" } "Vim support"