示例#1
0
        public static Result <char> Demo_WithBind()
        {
            string        sentence   = "Hello World";
            Result <char> charToFind = ResultMonad.Unit('H');

            Result <char> nextChar = charToFind
                                     .Bind(chr => GetIndexOfCharacter(sentence, chr))
                                     .Bind(index => GetCharacterAtIndex(sentence, index + 1));

            return(nextChar);
        }
示例#2
0
        public static Result <char> Demo_WithUnitAndBind_Linq()
        {
            string        sentence = "Hello World";
            Result <char> toFind   = ResultMonad.Unit('H');

            Result <char> result =
                from chr in toFind
                from index in GetIndexOfCharacter(sentence, chr)
                from nextChar in GetCharacterAtIndex(sentence, index + 1)
                select nextChar;

            return(result);
        }