Factor Documentation
|
Home
|
Glossary
|
Search
factorcode.org
sterling ( n k -- x )
Vocabulary
math.extras
Inputs and outputs
n
an
integer
k
an
integer
x
an
integer
Word description
Return the Stirling number of the second kind for a set with
n
elements partitioned into
k
disjoint non-empty sets.
Definition
USING:
combinators.short-circuit
kernel
math.extras.private
memoize
;
IN:
math.extras
MEMO:
sterling
( n k -- x )
2dup
{
[
=
]
[
nip
1
=
]
}
2||
[
2drop
1
]
[
(sterling)
]
if
;