]> gitweb.factorcode.org Git - factor.git/commitdiff
benchmark.pidigits: simplify handling of arrays.
authorJohn Benediktsson <mrjbq7@gmail.com>
Sun, 7 Apr 2013 22:33:54 +0000 (15:33 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Sun, 7 Apr 2013 22:33:54 +0000 (15:33 -0700)
extra/benchmark/pidigits/pidigits.factor

index a1daa9ecf05921455ea5104b0a007bc71cf33f7d..efcb3f3a1e8151b03104c8fd96c4f3e5c00f3e54 100644 (file)
@@ -1,13 +1,13 @@
 ! 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 ;
+USING: arrays formatting fry grouping io kernel locals math
+math.functions math.matrices math.parser math.primes.factors
+math.vectors prettyprint sequences sequences.deep ;
 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,7 +16,7 @@ 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. ;