Created
July 8, 2022 09:08
-
-
Save JonCanning/70ca7d4ac0db22d320f898fc1e12333d to your computer and use it in GitHub Desktop.
Dedupe items in a seq
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
let dedupe source = | |
seq { | |
let mutable previous = ValueNone | |
for item in source do | |
match previous with | |
| ValueSome x when x = item -> () | |
| _ -> yield item | |
previous <- ValueSome item | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment