-! Copyright (c) 2007 Aaron Schaefer.
+! Copyright (c) 2007, 2008 Aaron Schaefer.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: combinators.lib kernel math math.functions math.parser namespaces
-sequences splitting grouping combinators.short-circuit ;
+USING: combinators.short-circuit grouping kernel math math.parser namespaces
+    sequences ;
 IN: math.text.english
 
 <PRIVATE

    ] if ;

: 3digits>text ( n -- str )
    dup hundreds-place swap tens-place append ;

: text-with-scale ( index seq -- str )
    dupd nth 3digits>text swap
    scale-numbers [
        " " swap 3append
    ] unless-empty ;

: append-with-conjunction ( str1 str2 -- newstr )
    over length zero? [

        and-needed? off
    ] if ;

: (recombine) ( str index seq -- newstr )
    2dup nth zero? [
        2drop
    ] [
        text-with-scale append-with-conjunction
    ] if ;

: recombine ( seq -- str )
    dup length 1 = [
        first 3digits>text
    ] [
        [ set-conjunction "" ] [ length ] [ ] tri
        [ (recombine) ] curry each
    ] if ;

: (number>text) ( n -- str )
