Skip to content

Instantly share code, notes, and snippets.

@ruxo
Last active February 9, 2023 23:15
Show Gist options
  • Select an option

  • Save ruxo/d86a1cf7128784f89963 to your computer and use it in GitHub Desktop.

Select an option

Save ruxo/d86a1cf7128784f89963 to your computer and use it in GitHub Desktop.
Split sequence into groups
// code from https://stackoverflow.com/questions/6736464/split-seq-in-f/6737659#6737659
let splitBy f input =
let i = ref 0
input
|> Seq.groupBy (fun x ->
if f x then incr i
!i)
|> Seq.map snd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment