示例#1
0
 /// <summary>
 /// Map function for list
 /// </summary>
 /// <param name="list"> List for change </param>
 /// <param name="function"> Changing function </param>
 /// <returns> Changed list </returns>
 public static List Map(List list, Func<int, int> function)
 {
     List newList = new List();
     for (int i = 0; i < list.GetLength(); ++i)
             newList.Add(function(list.GetElement(i)));
     return newList;
 }
示例#2
0
 /// <summary>
 /// Filter list function
 /// </summary>
 /// <param name="list"> List for checking </param>
 /// <param name="function"> Function for filter </param>
 /// <returns> Filtered list </returns>
 public static List Filter(List list, Func<int, bool> function)
 {
     List newList = new List();
     for (int i = 0; i < list.GetLength(); ++i)
         if (function(list.GetElement(i)))
             newList.Add(list.GetElement(i));
     return newList;
 }