Skip to content

Instantly share code, notes, and snippets.

Created March 8, 2013 12:41
Show Gist options
  • Save anonymous/5116235 to your computer and use it in GitHub Desktop.
Save anonymous/5116235 to your computer and use it in GitHub Desktop.
コレクション中に同じ要素を含むか。
open System
type Foo = { Field : int }
let random = Random ()
Seq.initInfinite id
//|> Seq.take 50 // 適当に小さな値を入れたら全部違う値になる気がする
|> Seq.map (fun i -> { Field = random.Next (100) })
|> Seq.scan (fun set key -> Set.add key set) Set.empty
|> Seq.windowed 2
|> Seq.exists (function [| x; y |] -> x = y | _ -> failwith "")
|> printfn "%b"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment