2 using System.Collections.Generic;
 
    5 using System.Threading.Tasks;
 
   13     public static class GeneralExtensions
 
   21         public static string Fmt(
this String s, params 
object[] args)
 
   23             return String.Format(s, args);
 
   31         public static IEnumerable<T1> Print<T1>(
this IEnumerable<T1> enumerable, Func<T1, string> selector)
 
   33             foreach (var i 
in enumerable)
 
   35                 Console.WriteLine(selector(i));
 
   44         public static IEnumerable<Tuple<T,T>> CirclularPairs<T>(
this IEnumerable<T> list)
 
   46             var prevItem = list.First();
 
   48             foreach (var item 
in list.Skip(1))
 
   50                 yield 
return new Tuple<T, T>(prevItem, item);
 
   53             yield 
return new Tuple<T, T>(list.Last(), list.First());
 
   61         public static IEnumerable<T[]> CircularTuples<T>(
this IEnumerable<T> list, 
int size)
 
   63             var bakedList = list.ToList();
 
   65             foreach (var i 
in Enumerable.Range(0, bakedList.Count))
 
   67                 var array = 
new T[size];
 
   68                 foreach (var j 
in Enumerable.Range(0, size))
 
   71                     if (index >= bakedList.Count)
 
   73                         index -= bakedList.Count;
 
   75                     array[j] = bakedList[index];
 
   84         public static bool EqualsAny<T>(
this T source, params T[] list)
 
   86             if (null == source) 
throw new ArgumentNullException(
"source");
 
   87             return list.Contains(source);
 
   93         public static IEnumerable<TResult> NetZip<TFirst, TSecond, TResult>
 
   94             (
this IEnumerable<TFirst> first, IEnumerable<TSecond> second, Func<TFirst, TSecond, TResult> resultSelector)
 
   96             return Enumerable.Zip(first, second, resultSelector);
 
  102         public static HashSet<T> ToHashSet<T>(
this IEnumerable<T> source)
 
  104             return new HashSet<T>(source);
 
  112         public static IEnumerable<T> PrintCount<T>(
this IEnumerable<T> source, 
string enumerableName)
 
  114             var l = source.ToList();
 
  115             Console.WriteLine(enumerableName + 
" has " + l.Count + 
" members");