- 1 名前:デフォルトの名無しさん mailto:sage [2007/08/02(木) 14:03:05 ]
- MSResearchから出てきた.NETで使える関数型言語のひとつF#
OCAMLの流れを汲むこの言語、いろいろと面白そうなことができそう。 まだまだ英語の情報しかないこの言語について、幅広く語れ。 research.microsoft.com/fsharp/fsharp.aspx
- 434 名前:デフォルトの名無しさん mailto:sage [2009/02/08(日) 18:21:09 ]
- この流れなら書ける
type fix<'a, 'b> = Fix of (fix<'a, 'b> -> ('a -> 'b)) let y f = (fun (Fix g as h) x -> f (g h) x) (Fix (fun (Fix g as h) x -> f (g h) x)) y (fun f x -> if x = 1 then 1 else x * f (x-1)) 5 // val it : int = 120 [1..10] |> List.map (y (fun f x -> if x <= 2 then 1 else f (x-1) + f (x-2))) // val it : int list = [1; 1; 2; 3; 5; 8; 13; 21; 34; 55]
- 435 名前:デフォルトの名無しさん mailto:sage [2009/02/08(日) 20:43:02 ]
- 同じ結論にたどり着いた
type Rec<'a,'b> = R of (Rec<'a,'b> -> ('a -> 'b));; //version1 let y f = let ymaker (R proc) = f(fun arg -> (proc (R proc)) arg) in ymaker (R ymaker);; //version1 extract let y f = (fun (R proc) -> f(fun arg -> (proc (R proc)) arg)) (R (fun (R proc) -> f(fun arg -> (proc (R proc)) arg)) );; //version 2 let R_inv (R f) = f;; let y f = let ymaker proc = f(fun arg -> (((R_inv proc) proc) arg)) in ymaker (R ymaker);; //version 2 extract let y f = (fun proc -> f(fun arg -> (((R_inv proc) proc) arg))) (R (fun proc -> f(fun arg -> (((R_inv proc) proc) arg))) );;
|

|