USING: io kernel math math.functions math.parser parser lexer namespaces make sequences splitting grouping combinators continuations ; IN: decimal SYMBOL: currency-token CHAR: $ \ currency-token set-global : split/ ( dollars spliter -- dollars cents ) 10 swap ^ [ * ] [ ] bi /mod round ; : decimal>string ( dec prec -- str ) split/ [ number>string ] bi@ "." glue ; : money>string ( decimal -- str ) 2 decimal>string ; : money. ( object -- ) money>string print ; ERROR: not-an-integer x ; : parse-decimal ( str -- atio ) "." split1 [ "-" ?head swap ] dip [ [ "0" ] when-empty ] bi@ [ [ dup string>number [ nip ] [ not-an-integer ] if* ] bi@ ] keep length 10 swap ^ / + swap [ neg ] when ; SYNTAX: DECIMAL: scan parse-decimal parsed ;