math.combinatorics: faster nCk (use integer division).
parent
a52ee59005
commit
d15dbaebb4
|
@ -24,7 +24,7 @@ MEMO: factorial ( n -- n! )
|
||||||
2dup possible? [ dupd - [a,b) product ] [ 2drop 0 ] if ;
|
2dup possible? [ dupd - [a,b) product ] [ 2drop 0 ] if ;
|
||||||
|
|
||||||
: nCk ( n k -- nCk )
|
: nCk ( n k -- nCk )
|
||||||
twiddle [ nPk ] keep factorial / ;
|
twiddle [ nPk ] keep factorial /i ;
|
||||||
|
|
||||||
|
|
||||||
! Factoradic-based permutation methodology
|
! Factoradic-based permutation methodology
|
||||||
|
@ -112,6 +112,7 @@ PRIVATE>
|
||||||
: next-permutation ( seq -- seq )
|
: next-permutation ( seq -- seq )
|
||||||
dup [ ] [ drop (next-permutation) ] if-empty ;
|
dup [ ] [ drop (next-permutation) ] if-empty ;
|
||||||
|
|
||||||
|
|
||||||
! Combinadic-based combination methodology
|
! Combinadic-based combination methodology
|
||||||
|
|
||||||
<PRIVATE
|
<PRIVATE
|
||||||
|
|
Loading…
Reference in New Issue