public void CataFinite() { Func <Func <Maybe <int> > > source = () => { int n = 0; return(() => n <= 3 ? (Maybe <int>) new Maybe <int> .Some(n ++) : new Maybe <int> .None()); }; for (int i = 0; i < 2; i++) { Assert.IsTrue(source.Cata(0, _ => true, (sum, x) => sum + x) == 6, "Invalid result (" + i + ")."); } }
public void CataEmpty() { Func <Func <Maybe <int> > > source = () => () => new Maybe <int> .None(); Assert.IsTrue(source.Cata(42, _ => true, (_, __) => _) == 42, "Invalid result."); }