Created
November 16, 2014 12:08
-
-
Save JefClaes/b482f8b6021f70153b7a to your computer and use it in GitHub Desktop.
streamIsHot function
This file contains hidden or 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
| let streamIsHot (events : seq<Event>) treshold secondsInWindow = | |
| let folder acc e = | |
| let detect acc e = | |
| let windowFilter = (fun x -> x >= e.Timestamp.AddSeconds(- float secondsInWindow)) | |
| let window = e.Timestamp :: acc.Window |> List.filter windowFilter | |
| let hot = (window |> Seq.length) > treshold | |
| { acc with Hot = hot; Window = window } | |
| match acc.Hot with | |
| | true -> acc | |
| | false -> detect acc e | |
| (Seq.fold folder initialDetectionResult events).Hot |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment