Beispiel #1
0
 public Locator(
     ImMap <string, ImMap <string, LocatorTarget> > registrationList,
     ImList <LocatorPlug> plugs
     )
 {
     RegistrationList = registrationList;
     Plugs            = plugs;
 }
Beispiel #2
0
 public static ImList <T> AddNew <T>(T item, ImList <T> list)
 {
     if (list.Has(item))
     {
         return(list);
     }
     return(list + item);
 }
Beispiel #3
0
 public static R Maybe <T, R>(Func <T, R> action, T item, R def, ImList <T> list)
 {
     if (list.Has(item))
     {
         return(action(item));
     }
     return(def);
 }
Beispiel #4
0
        public static ImList <T> Transform <T>(Func <T, T> iterator, ImList <T> list)
        {
            var transformedList = Im.Fold <T, List <T> >((List <T> acc, T item) => {
                acc.Insert(0, iterator(item));
                return(acc);
            }, new List <T>(), list);

            return(new ImList <T>(transformedList));
        }
Beispiel #5
0
        public static void Each <T>(Action <T> iterator, ImList <T> list)
        {
            var lst = list.GetList();

            foreach (T item in lst)
            {
                iterator(item);
            }
        }
Beispiel #6
0
        public static R Fold <T, R>(Func <R, T, R> iterator, R initialValue, ImList <T> list)
        {
            var lst = list.GetList();
            var acc = initialValue;

            foreach (T item in lst)
            {
                acc = iterator(acc, item);
            }
            return(acc);
        }
Beispiel #7
0
 public static ImList <T> Replace <T>(Func <T, bool> predicate, T newItem, ImList <T> list)
 {
     for (int x = 0; x < list.Count; x++)
     {
         if (predicate(list[x]))
         {
             var lst = list.GetList();
             lst[x] = newItem;
             return(new ImList <T>(lst));
         }
     }
     return(list + newItem);
 }
Beispiel #8
0
        public static T Find <T>(Func <T, bool> iterator, ImList <T> list)
        {
            var lst = list.GetList();

            foreach (T item in lst)
            {
                if (iterator(item))
                {
                    return(item);
                }
            }
            return(default(T));
        }
Beispiel #9
0
        public static T Last <T>(ImList <T> list)
        {
            var count = list.Count;

            return(list[count - 1]);
        }
Beispiel #10
0
 public static T Head <T>(ImList <T> list)
 {
     return(list[0]);
 }
Beispiel #11
0
 public static Func <ImList <T>, ImList <T> > Overlay <T>(Func <T, T, bool> predicate, ImList <T> list1)
 {
     return(Curry <Func <T, T, bool>, ImList <T>, ImList <T>, ImList <T> > .New(Overlay)(predicate)(list1));
 }
Beispiel #12
0
 public static ImList <T> Overlay <T>(Func <T, T, bool> predicate, ImList <T> list1, ImList <T> list2)
 {
     return(Fold((acc, item) => Replace((item1) => predicate(item1, item), item, acc), list1, list2));
 }
Beispiel #13
0
 public static ImList <T> Uniq <T>(ImList <T> list)
 {
     return(Fold((acc, item) => AddNew(item, acc), new ImList <T>(), list));
 }
Beispiel #14
0
 public static bool Has <T>(T item, ImList <T> list)
 {
     return(list.Has(item));
 }