From fc384c433b9380d4d958814de3c77cd073adb1bd Mon Sep 17 00:00:00 2001 From: Samuel Tardieu Date: Fri, 23 Jan 2009 15:22:03 +0100 Subject: [PATCH] Put 3digit-groups into its own vocabulary --- extra/math/text/english/english.factor | 7 ++----- extra/math/text/utils/authors.txt | 1 + extra/math/text/utils/summary.txt | 1 + extra/math/text/utils/utils-docs.factor | 6 ++++++ extra/math/text/utils/utils-tests.factor | 3 +++ extra/math/text/utils/utils.factor | 7 +++++++ 6 files changed, 20 insertions(+), 5 deletions(-) create mode 100644 extra/math/text/utils/authors.txt create mode 100644 extra/math/text/utils/summary.txt create mode 100644 extra/math/text/utils/utils-docs.factor create mode 100644 extra/math/text/utils/utils-tests.factor create mode 100644 extra/math/text/utils/utils.factor diff --git a/extra/math/text/english/english.factor b/extra/math/text/english/english.factor index 643fc3ae05..5a10e7af37 100755 --- a/extra/math/text/english/english.factor +++ b/extra/math/text/english/english.factor @@ -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 ] [ 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 index 0000000000..4eec9c9a08 --- /dev/null +++ b/extra/math/text/utils/authors.txt @@ -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 index 0000000000..b2d8744879 --- /dev/null +++ b/extra/math/text/utils/summary.txt @@ -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 index 0000000000..e1d1a005d3 --- /dev/null +++ b/extra/math/text/utils/utils-docs.factor @@ -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 index 0000000000..d14bb06a2a --- /dev/null +++ b/extra/math/text/utils/utils-tests.factor @@ -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 index 0000000000..73326de273 --- /dev/null +++ b/extra/math/text/utils/utils.factor @@ -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 ;