I am attempting to write a function that weeds out consecutive duplicates, as determined by a given equality function, from a seq<\'a>
but with a twist:
I'm also looking forward to a non-seq answer. Here's another solution:
let t = [("a", 1); ("b", 2); ("b", 3); ("b", 4); ("c", 5)]
t |> Seq.groupBy fst |> Seq.map (snd >> Seq.last)
I tested on a 1M list:
Real: 00:00:00.000, CPU: 00:00:00.000, GC gen0: 0, gen1: 0, gen2: 0
val it : seq = seq [(2, 2); (1, 1)]