-
-
Save kos59125/5116257 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System | |
type Foo = { Field : int } | |
let random = Random () | |
let hasDuplicate keySelector = | |
let adjacent = Seq.windowed 2 >> Seq.map (function | [| x; y |] -> x, y | _ -> failwith "invalid") | |
Seq.scan (fun set value -> Set.add (keySelector value) set) Set.empty | |
>> adjacent | |
>> Seq.exists (fun (x, y) -> Set.count x = Set.count y) | |
Seq.initInfinite (fun _ -> { Field = random.Next (1000) }) | |
//|> Seq.take 50 // 適当に小さな値を入れたら全部違う値になる気がする | |
|> hasDuplicate (fun foo -> foo.Field) | |
|> printfn "%b" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment