Skip to content

Instantly share code, notes, and snippets.

@evanricard
Last active September 2, 2020 00:20
Show Gist options
  • Save evanricard/2b06cd21fcd7476406934c637e183da7 to your computer and use it in GitHub Desktop.
Save evanricard/2b06cd21fcd7476406934c637e183da7 to your computer and use it in GitHub Desktop.
Gulag-derived predicate syntax
public static Func<T, bool> Not<T>(this Func<T, bool> predicate)
{
    return a => !predicate(a);
}
 
public static Func<T, bool> And<T>(this Func<T, bool> left, Func<T, bool> right)
{
    return a => left(a) && right(a);
}
 
public static Func<T, bool> Or<T>(this Func<T, bool> left, Func<T, bool> right)
{
    return a => left(a) || right(a);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment