]> gitweb.factorcode.org Git - factor.git/commitdiff
math.combinatorics: factorial could be memoized...
authorJohn Benediktsson <mrjbq7@gmail.com>
Wed, 5 Sep 2012 18:02:38 +0000 (11:02 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Wed, 5 Sep 2012 18:02:38 +0000 (11:02 -0700)
basis/math/combinatorics/combinatorics.factor

index 665629dce75269850fe5784d0cfa9c88a9c15803..9930cb94f84647e31f0deaa498b2d8eac903fe0c 100644 (file)
@@ -2,8 +2,8 @@
 ! See http://factorcode.org/license.txt for BSD license.
 
 USING: accessors arrays assocs binary-search classes.tuple fry
-kernel locals math math.order math.ranges namespaces sequences
-sequences.private sorting ;
+kernel locals math math.order math.ranges memoize namespaces
+sequences sequences.private sorting ;
 FROM: sequences => change-nth ;
 IN: math.combinatorics
 
@@ -17,7 +17,7 @@ IN: math.combinatorics
 
 PRIVATE>
 
-: factorial ( n -- n! )
+MEMO: factorial ( n -- n! )
     dup 1 > [ [1,b] product ] [ drop 1 ] if ;
 
 : nPk ( n k -- nPk )