benchmark.pidigits: simplify handling of arrays.

db4
John Benediktsson 2013-04-07 15:33:54 -07:00
parent ed95bcc8b9
commit 0431acf97e
1 changed files with 5 additions and 5 deletions

View File

@ -1,13 +1,13 @@
! Copyright (c) 2009 Aaron Schaefer. All rights reserved. ! Copyright (c) 2009 Aaron Schaefer. All rights reserved.
! The contents of this file are licensed under the Simplified BSD License ! 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 ! A copy of the license is available at http://factorcode.org/license.txt
USING: arrays formatting fry grouping io kernel locals math math.functions USING: arrays formatting fry grouping io kernel locals math
math.matrices math.parser math.primes.factors math.vectors prettyprint math.functions math.matrices math.parser math.primes.factors
sequences sequences.deep ; math.vectors prettyprint sequences sequences.deep ;
IN: benchmark.pidigits IN: benchmark.pidigits
: extract ( z x -- n ) : extract ( z x -- n )
1 2array '[ _ v* sum ] map first2 /i ; [ first2 ] dip '[ first2 [ _ * ] [ + ] bi* ] bi@ /i ;
: next ( z -- n ) : next ( z -- n )
3 extract ; 3 extract ;
@ -16,7 +16,7 @@ IN: benchmark.pidigits
[ 4 extract ] dip = ; [ 4 extract ] dip = ;
: >matrix ( q s r t -- z ) : >matrix ( q s r t -- z )
4array 2 group ; [ 2array ] 2bi@ 2array ;
: produce ( z y -- z' ) : produce ( z y -- z' )
[ 10 ] dip -10 * 0 1 >matrix swap m. ; [ 10 ] dip -10 * 0 1 >matrix swap m. ;