RosettaCodeData/Task/Sudan-function/Factor/sudan-function-2.factor

9 lines
208 B
Factor

USING: combinators kernel locals math prettyprint ;
:: sudan ( n x y -- z )
{
{ [ n zero? ] [ x y + ] }
{ [ y zero? ] [ x ] }
[ n 1 - n x y 1 - sudan dup y + sudan ]
} cond ;