2016-10-18 6 views

答えて

3
> apply (\n -> n * ??? (n - 1)) 3 -- compute a factorial 
6 

インポートData.Function引数

> import Data.Function 
> :t fix 
fix :: (a -> a) -> a 
> apply (fix $ \f n -> if n == 0 then 1 else n * f (n - 1)) 3 
6 
ように再帰的に適用する関数を取る -recursive関数の固定点を計算する fix関数を使用
関連する問題