Skip to content

Instantly share code, notes, and snippets.

@deviousasti
Last active July 6, 2020 12:37
Show Gist options
  • Save deviousasti/dcc8684b77877bad73ea734825fd7455 to your computer and use it in GitHub Desktop.
Save deviousasti/dcc8684b77877bad73ea734825fd7455 to your computer and use it in GitHub Desktop.
let createComparer (map) =
{
new EqualityComparer<_>() with
override this.Equals(a, b) = Unchecked.equals (map a) (map b)
override this.GetHashCode(a) = Unchecked.hash (map a)
}
module Seq =
let exceptWith map first second =
Enumerable.Except(first, second, createComparer map)
(*
Example:
> [(1, 2); (3, 4)] |> Seq.exceptWith fst [(1, 3); (5, 7)];;
val it : IEnumerable<int * int> = seq [(5, 7)]
*)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment