]> gitweb.factorcode.org Git - factor.git/blobdiff - extra/benchmark/pidigits/pidigits.factor
factor: trim using lists
[factor.git] / extra / benchmark / pidigits / pidigits.factor
index 0f8a98e6f9dede654385dd0e5472d0702acf1546..45b4c9becbeffbdff65c591ab8ed23d77f4047a3 100644 (file)
@@ -1,13 +1,12 @@
 ! Copyright (c) 2009 Aaron Schaefer. All rights reserved.
 ! The contents of this file are licensed under the Simplified BSD License
 ! A copy of the license is available at http://factorcode.org/license.txt
-USING: arrays formatting fry grouping io kernel locals math math.functions
-    math.matrices math.parser math.primes.factors math.vectors prettyprint
-    sequences sequences.deep sets ;
+USING: arrays formatting io kernel math math.matrices
+math.parser sequences ;
 IN: benchmark.pidigits
 
 : extract ( z x -- n )
-    1 2array '[ _ v* sum ] map first2 /i ;
+    [ first2 ] dip '[ first2 [ _ * ] [ + ] bi* ] bi@ /i ;
 
 : next ( z -- n )
     3 extract ;
@@ -16,16 +15,16 @@ IN: benchmark.pidigits
     [ 4 extract ] dip = ;
 
 : >matrix ( q s r t -- z )
-    4array 2 group ;
+    [ 2array ] 2bi@ 2array ;
 
 : produce ( z y -- z' )
-    [ 10 ] dip -10 * 0 1 >matrix swap m. ;
+    [ 10 ] dip -10 * 0 1 >matrix swap mdot ;
 
 : gen-x ( x -- matrix )
     dup 2 * 1 + [ 2 * 0 ] keep >matrix ;
 
 : consume ( z k -- z' )
-    gen-x m. ;
+    gen-x mdot ;
 
 :: (padded-total) ( row col -- str n format )
     "" row col + "%" "s\t:%d\n"
@@ -53,7 +52,7 @@ IN: benchmark.pidigits
 : pidigits ( n -- )
     [ 1 { { 1 0 } { 0 1 } } ] dip 0 0 (pidigits) ;
 
-: pidigits-main ( -- )
-    10000 pidigits ;
+: pidigits-benchmark ( -- )
+    2000 pidigits ;
 
-MAIN: pidigits-main
+MAIN: pidigits-benchmark