1 ! Copyright (C) 2012 John Benediktsson
2 ! See http://factorcode.org/license.txt for BSD license
4 USING: combinators kernel math math.combinatorics math.ranges
7 IN: benchmark.combinatorics
9 : bench-combinations ( n -- )
12 [ all-combinations drop ]
13 [ [ drop ] each-combination ]
14 [ [ first 2 = ] find-combination drop ]
15 [ 0 [ sum + ] reduce-combinations drop ]
19 : bench-permutations ( n -- )
21 [ all-permutations drop ]
22 [ [ drop ] each-permutation ]
23 [ [ first 2 = ] find-permutation drop ]
24 [ 0 [ sum + ] reduce-permutations drop ]
27 : combinatorics-benchmark ( -- )
28 15 bench-combinations 8 bench-permutations ;
30 MAIN: combinatorics-benchmark