プログラミング入門

2fe24944 :Anonymous 2015-10-07 07:21
>>c432f487 です
きちんとした環境を整えた&自分の技術力が向上したのでかきなおしました
割とトラップ多めで手こずりましたがだんだん慣れてきた

open System
let main =
printfn "何種類の整数を使いますか?"
let max = parse (Console.ReadLine())
printfn "1以上%d以下の整数を何個でも入力してください" max
let l =
Console.ReadLine().Split ','
|>Seq.map parse
|>Seq.fold (fun x y -> if (List.isEmpty x || List.head x <> y) then y::x else x) []
|>Seq.groupBy(fun x -> x)
|>Seq.sortBy fst
if Seq.length l > max then printfn "入力エラー"
else l|>Seq.iter (fun x -> printfn "%dは%dグループあります" (fst x) (Seq.length (snd x)));;
Powered by shinGETsu.