]> gitweb.factorcode.org Git - factor.git/blob - extra/benchmark/e-decimals/e-decimals.factor
factor: trim using lists
[factor.git] / extra / benchmark / e-decimals / e-decimals.factor
1 ! Copyright (C) 2009 Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: decimals kernel math ranges sequences ;
4 IN: benchmark.e-decimals
5
6 : D-factorial ( n -- D! )
7     <iota> DECIMAL: 1 [ 0 <decimal> DECIMAL: 1 D+ D* ] reduce ; inline
8
9 :: calculate-e-decimals ( n -- e )
10     n [1..b] DECIMAL: 1
11     [ D-factorial DECIMAL: 1 swap n D/ D+ ] reduce ;
12
13 : e-decimals-benchmark ( -- )
14     5 [ 800 calculate-e-decimals drop ] times ;
15
16 MAIN: e-decimals-benchmark