【激突】関数型言語 VS オブジェクト指向言語2at TECH【激突】関数型言語 VS オブジェクト指向言語2 - 暇つぶし2ch■コピペモード□スレを通常表示□オプションモード□このスレッドのURL■項目テキスト341:デフォルトの名無しさん 12/04/14 05:12:11.99 F#で演算子オーバーロードなし。 let threadLocal = new System.Threading.ThreadLocal<_>() let makeFizzBuzz name condition (x : obj) = match x with | :? int as number -> threadLocal.Value <- number if condition number then box name else box number | :? string as names -> box (if condition threadLocal.Value then names + name else names) | _ -> failwith "ロジックエラー" let fizz = makeFizzBuzz "Fizz" (fun x -> x % 3 = 0) let buzz = makeFizzBuzz "Buzz" (fun x -> x % 5 = 0) let gizz = makeFizzBuzz "Gizz" (fun x -> x % 7 = 0) > [1; 3; 5; 7; 15; 21; 35; 105] |> List.map (fun x -> gizz(buzz(fizz x)));; val it : obj list = [1; "Fizz"; "Buzz"; "Gizz"; "FizzBuzz"; "FizzGizz"; "BuzzGizz"; "FizzBuzzGizz"] 342:デフォルトの名無しさん 12/04/14 05:26:59.93 さーて、また関数型言語が不利になるルールが追加されるよー 次ページ最新レス表示レスジャンプ類似スレ一覧スレッドの検索話題のニュースおまかせリストオプションしおりを挟むスレッドに書込スレッドの一覧暇つぶし2ch