]> gitweb.factorcode.org Git - factor.git/commitdiff
math.parser: remove digits>integer.
authorJohn Benediktsson <mrjbq7@gmail.com>
Mon, 20 Jul 2015 01:06:51 +0000 (18:06 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Mon, 20 Jul 2015 02:18:47 +0000 (19:18 -0700)
core/math/parser/parser-docs.factor
core/math/parser/parser.factor

index 9cefe5231990d807ea565ad88e56dd97a11a76bc..66456d7bfde96345b038818c703f357e9fee9621 100644 (file)
@@ -28,11 +28,6 @@ $nl
 
 ABOUT: "number-strings"
 
-HELP: digits>integer
-{ $values { "seq" "a sequence of integers" } { "radix" "an integer between 2 and 16" } { "n/f" { $maybe integer } } }
-{ $description "Converts a sequence of digits (with most significant digit first) into an integer." }
-{ $notes "This is one of the factors of " { $link string>number } "." } ;
-
 HELP: >digit
 { $values { "n" "an integer between 0 and 15" } { "ch" "a character" } }
 { $description "Outputs a character representation of a digit." }
index ec424716b942f26db3a64d49f75098165fa3eaad..4fef37287a7b1e5bf3ca098a8ba7cc7593f7c675 100644 (file)
@@ -16,6 +16,12 @@ PRIVATE>
                              [ CHAR: a 10 - - dup 10 < [ drop 255 ] when ]
     } cond ; inline
 
+: string>digits ( str -- digits )
+    [ digit> ] B{ } map-as ; inline
+
+: >digit ( n -- ch )
+    dup 10 < [ CHAR: 0 + ] [ 10 - CHAR: a + ] if ; inline
+
 ERROR: invalid-radix radix ;
 
 <PRIVATE
@@ -307,25 +313,6 @@ PRIVATE>
 : dec> ( str -- n/f ) 10 base> ; inline
 : hex> ( str -- n/f ) 16 base> ; inline
 
-: string>digits ( str -- digits )
-    [ digit> ] B{ } map-as ; inline
-
-<PRIVATE
-
-: (digits>integer) ( valid? accum digit radix -- valid? accum )
-    2dup < [ swapd * + ] [ 4drop f 0 ] if ; inline
-
-: each-digit ( seq radix quot -- n/f )
-    [ t 0 ] 3dip curry each swap [ drop f ] unless ; inline
-
-PRIVATE>
-
-: digits>integer ( seq radix -- n/f )
-    [ (digits>integer) ] each-digit ; inline
-
-: >digit ( n -- ch )
-    dup 10 < [ CHAR: 0 + ] [ 10 - CHAR: a + ] if ; inline
-
 <PRIVATE
 
 CONSTANT: TENS B{