Tech Off Post

Single Post Permalink

View Thread: Functional Style Boolean Logic in C#
  • User profile image

    Are their any issues with this approach?  I'm also trying to follow a very function first style so am I doing that correctly.  Also can anyone see a way to make this shorter.  For instance I hate having to repeat the signatures twice every time.  var will not work here.  I'm trying to do something similar to what Erik did here. 



        abstract class Bool
            public static readonly Bool True = new True();
            public static readonly Bool False = new False();
            public static readonly Func<Bool, Bool> Not =
                new Func<Bool, Bool>(a => a is True ? False : True );
            public static readonly Func<Bool, Func<Bool, Bool>> And =
                new Func<Bool, Func<Bool, Bool>>(a => b => a is True ? b : a);
        class True : Bool {}
        class False : Bool {}