sterling ( n k -- x )


Vocabulary
math.extras

Inputs and outputs
nan integer
kan integer
xan 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 ;