From c86b2d2161d0ae0953136f029f040d7948a83313 Mon Sep 17 00:00:00 2001 From: John Benediktsson Date: Wed, 5 Sep 2012 11:02:38 -0700 Subject: [PATCH] math.combinatorics: factorial could be memoized... --- basis/math/combinatorics/combinatorics.factor | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/basis/math/combinatorics/combinatorics.factor b/basis/math/combinatorics/combinatorics.factor index 665629dce7..9930cb94f8 100644 --- a/basis/math/combinatorics/combinatorics.factor +++ b/basis/math/combinatorics/combinatorics.factor @@ -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 )