math.combinatorics: factorial could be memoized...
parent
e36c76cadf
commit
c86b2d2161
|
@ -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 )
|
||||
|
|
Loading…
Reference in New Issue