示例#1
0
        public static void Sample_Generic()
        {
            //this example shows how to use GenericSequence to solve problem

            //How many distinct terms are in the sequence generated by a^b for 2 ≤ a ≤ 100 and 2 ≤ b ≤ 100?
            //(Question from http://projecteuler.net)
            Console.WriteLine((from x in 2.To(100)
                               from y in SequenceExt.Create((BigInteger)x * x, n => n * x).Take(99)
                               select y).Distinct().Count());
        }
示例#2
0
        public static void GenericSequence()
        {
            //this example shows how to create generice infinite sequence

            //you can create GenericeSequence by SequenceExt.Create(seed, selector)
            //if you omit seed, default(T) is assumed
            //below is to create odd number sequence
            var oddNum = SequenceExt.Create(1, x => x + 2);

            //show result
            Console.WriteLine(oddNum.Take(25).ToString(", "));
        }