Example #1
0
 /// <summary>
 /// Maps a function over a set and returns a dictionary-based result
 /// </summary>
 /// <typeparam name="X">The function input type</typeparam>
 /// <typeparam name="Y">The function output type</typeparam>
 /// <param name="values">The values to be evaluated</param>
 /// <param name="f">The evaulator</param>
 /// <param name="PLL">Whether to evaulate concurrently</param>
 /// <returns></returns>
 public static IReadOnlyDictionary <X, Y> eval <X, Y>(IReadOnlySet <X> values, Func <X, Y> f, bool PLL = true)
 {
     if (PLL)
     {
         var data = new ConcurrentDictionary <X, Y>();
         values.AsParallel().ForAll(p => data[p] = f(p));
         return(data);
     }
     else
     {
         return(dict(map(values, p => (p, f(p)))));
     }
 }