]> gitweb.factorcode.org Git - factor.git/commitdiff
math: using until-zero in a few places.
authorJohn Benediktsson <mrjbq7@gmail.com>
Mon, 7 Dec 2020 18:28:08 +0000 (10:28 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Mon, 7 Dec 2020 18:28:08 +0000 (10:28 -0800)
core/math/parser/parser.factor
extra/base58/base58.factor
extra/benchmark/ant/ant.factor

index a450b2b7f014ff73c158ddb30219efc2e0af6510..30537bf6f1a4d426c7586c1c6173b8e663642ae7 100644 (file)
@@ -88,11 +88,10 @@ TUPLE: float-parse
     [ store-exponent ] [ drop f ] if* ; inline
 
 : pow-until ( base x -- base^x )
-    [ 1 ] 2dip
-    [ dup zero? ] [
+    [ 1 ] 2dip [
         dup odd? [ [ [ * ] keep ] [ 1 - ] bi* ] when
         [ sq ] [ 2/ ] bi*
-    ] until 2drop ; inline
+    ] until-zero drop ; inline
 
 : (pow) ( base x -- base^x )
     integer>fixnum-strict
index 122a5c50462d7b9e40bd8b93fc0bbbbbb01a3635..a3601a7856d98c671d6fa496eb6f2d5bcd333c4e 100644 (file)
@@ -30,7 +30,7 @@ PRIVATE>
     BV{ } clone :> accum
     seq [ zero? not ] find [ drop seq length ] unless :> i
     seq i tail-slice be>
-    [ dup zero? ] [ 58 /mod ch>base58 accum push ] until drop
+    [ 58 /mod ch>base58 accum push ] until-zero
     i alphabet first '[ _ accum push ] times
     accum reverse! B{ } like ;
 
@@ -39,7 +39,7 @@ PRIVATE>
     base58 alphabet first '[ _ = not ] find
     [ drop base58 length ] unless :> i
     0 base58 [ [ 58 * ] dip base58>ch + ] i each-from
-    [ dup zero? ] [ 256 /mod accum push ] until drop
+    [ 256 /mod accum push ] until-zero
     i [ 0 accum push ] times
     accum reverse! B{ } like ;
 
index 1946a25a1de466592f1a72210cdb5bc9f384a438..4542707786286c42a5dee28e0cee1d529e7ee986 100644 (file)
@@ -21,7 +21,7 @@ IN: benchmark.ant
 ! including (1000, 1000) itself?
 
 : sum-digits ( n -- x )
-    0 swap [ dup zero? ] [ 10 /mod swap [ + ] dip ] until drop ;
+    0 swap [ 10 /mod swap [ + ] dip ] until-zero ;
 
 TUPLE: point x y ;
 C: <point> point