]> gitweb.factorcode.org Git - factor.git/commitdiff
factor out money>string
authorDoug Coleman <doug.coleman@gmail.com>
Sat, 6 Sep 2008 18:58:14 +0000 (13:58 -0500)
committerDoug Coleman <doug.coleman@gmail.com>
Sat, 6 Sep 2008 18:58:14 +0000 (13:58 -0500)
extra/money/money.factor

index ba7a0ae04fc964d353bebae0f718bab1d07e457a..bf9f4d3a67952ba0a4089c1b5f72697bf9035b9a 100644 (file)
@@ -6,14 +6,16 @@ IN: money
 : dollars/cents ( dollars -- dollars cents )
     100 * 100 /mod round ;
 
-: money. ( object -- )
-    dollars/cents
-    [
+: money>string ( object -- string )
+    dollars/cents [
         "$" %
         swap number>string
         <reversed> 3 group "," join <reversed> %
         "." % number>string 2 CHAR: 0 pad-left %
-    ] "" make print ;
+    ] "" make ;
+
+: money. ( object -- )
+    money>string print ;
 
 ERROR: not-a-decimal x ;