]> gitweb.factorcode.org Git - factor.git/commitdiff
Put 3digit-groups into its own vocabulary
authorSamuel Tardieu <sam@rfc1149.net>
Fri, 23 Jan 2009 14:22:03 +0000 (15:22 +0100)
committerSamuel Tardieu <sam@rfc1149.net>
Fri, 23 Jan 2009 14:22:03 +0000 (15:22 +0100)
extra/math/text/english/english.factor
extra/math/text/utils/authors.txt [new file with mode: 0644]
extra/math/text/utils/summary.txt [new file with mode: 0644]
extra/math/text/utils/utils-docs.factor [new file with mode: 0644]
extra/math/text/utils/utils-tests.factor [new file with mode: 0644]
extra/math/text/utils/utils.factor [new file with mode: 0644]

index 643fc3ae051bc94c46327d9b4185e6284655eb38..5a10e7af37009b412edecb9adb2b4d773aba2e1d 100755 (executable)
@@ -1,7 +1,7 @@
 ! Copyright (c) 2007, 2008 Aaron Schaefer.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: combinators.short-circuit grouping kernel math math.parser namespaces
-    sequences ;
+USING: combinators.short-circuit grouping kernel math math.parser
+math.text.utils namespaces sequences ;
 IN: math.text.english
 
 <PRIVATE
@@ -31,9 +31,6 @@ SYMBOL: and-needed?
 : negative-text ( n -- str )
     0 < "Negative " "" ? ;
 
-: 3digit-groups ( n -- seq )
-    [ dup 0 > ] [ 1000 /mod ] [ ] produce nip ;
-
 : hundreds-place ( n -- str )
     100 /mod over 0 = [
         2drop ""
diff --git a/extra/math/text/utils/authors.txt b/extra/math/text/utils/authors.txt
new file mode 100644 (file)
index 0000000..4eec9c9
--- /dev/null
@@ -0,0 +1 @@
+Aaron Schaefer
diff --git a/extra/math/text/utils/summary.txt b/extra/math/text/utils/summary.txt
new file mode 100644 (file)
index 0000000..b2d8744
--- /dev/null
@@ -0,0 +1 @@
+Number to text conversion utilities
diff --git a/extra/math/text/utils/utils-docs.factor b/extra/math/text/utils/utils-docs.factor
new file mode 100644 (file)
index 0000000..e1d1a00
--- /dev/null
@@ -0,0 +1,6 @@
+USING: help.markup help.syntax ;
+IN: math.text.utils
+
+HELP: 3digit-groups
+{ $values { "n" "a positive integer" } { "seq" "a sequence" } }
+{ $description "Decompose a number into 3 digits groups and return them in a sequence, starting with the units, then the tenths, etc." } ;
diff --git a/extra/math/text/utils/utils-tests.factor b/extra/math/text/utils/utils-tests.factor
new file mode 100644 (file)
index 0000000..d14bb06
--- /dev/null
@@ -0,0 +1,3 @@
+USING: math.text.utils tools.test ;
+
+[ { 1 999 2 } ] [ 2999001 3digit-groups ] unit-test
diff --git a/extra/math/text/utils/utils.factor b/extra/math/text/utils/utils.factor
new file mode 100644 (file)
index 0000000..73326de
--- /dev/null
@@ -0,0 +1,7 @@
+! Copyright (c) 2007, 2008 Aaron Schaefer.
+! See http://factorcode.org/license.txt for BSD license.
+USING: kernel math sequences ;
+IN: math.text.utils
+
+: 3digit-groups ( n -- seq )
+    [ dup 0 > ] [ 1000 /mod ] [ ] produce nip ;