public static ListArrow <A, C> Combine <A, B, C>(this ListArrow <A, B> a1, ListArrow <B, C> a2)
        {
            /*
             * Combine arrows end-to-end. This is an overloaded version of the normal Arrow.Combine
             * method used to prevent ListArrows being prematurely converted into arrows between
             * IEnumerables.
             */

            ListArrow <A, C> result = new ListArrow <A, C>(
                x => a2.Invoke(a1.Invoke(x))
                );

            return(result);
        }
Esempio n. 2
0
        public static void DemoListArrows()
        {
            List <String> cities = new List <String> {
                "London",
                "Edinburgh",
                "Newcastle",
                "Manchester",
                "Glasgow",
                "Cambridge"
            };

            ListArrow <String, String> sorter = ListArrow.Map((String x) => Tuple.Create(x, x.Length))
                                                .Combine(ListArrow.OrderBy <Tuple <String, int> >((s1, s2) => s1.Item2 - s2.Item2)
                                                         .Combine(ListArrow.Map((Tuple <String, int> x) => x.Item1)))
                                                .Combine(ListArrow.Filter((String x) => x.IndexOf('E') != 0));

            var result = sorter.Invoke(cities);

            foreach (var s in result)
            {
                Console.WriteLine(s);
            }

            Console.WriteLine();

            ListArrow <String, String> cityArrow =
                ListArrow.Map((String city) => Tuple.Create(city, city.Length))
                .Filter((Tuple <String, int> cityTuple) => cityTuple.Item2 > 7)
                .Map((Tuple <String, int> cityTuple) => cityTuple.Item1)
                .Filter((String city) => city != "Manchester")
                .OrderBy((String c1, String c2) => c1.CompareTo(c2));

            result = cityArrow.Invoke(cities);
            foreach (var s in result)
            {
                Console.WriteLine(s);
            }
        }
Esempio n. 3
0
 private void RunArrow(List <Person> input)
 {
     arrow.Invoke(input);
 }