コード例 #1
0
 /// <summary>
 ///     Wraps delegate to an F# function
 /// </summary>
 /// <typeparam name="S1"></typeparam>
 /// <typeparam name="S2"></typeparam>
 /// <typeparam name="S3"></typeparam>
 /// <param name="func">Input delegate.</param>
 /// <returns>An F# lambda wrapper.</returns>
 public static FSharpFunc <S1, FSharpFunc <S2, FSharpFunc <S3, unit> > > ToFSharpFunc <S1, S2, S3>(this Action <S1, S2, S3> func)
 {
     return(FSharpFunc.Create(func));
 }
コード例 #2
0
 /// <summary>
 ///     Wraps delegate to an F# function
 /// </summary>
 /// <param name="func">Input delegate.</param>
 /// <returns>An F# lambda wrapper.</returns>
 public static FSharpFunc <unit, unit> ToFSharpFunc(this Action func)
 {
     return(FSharpFunc.Create(func));
 }
コード例 #3
0
 /// <summary>
 ///     Wraps delegate to an F# function
 /// </summary>
 /// <typeparam name="S"></typeparam>
 /// <param name="func">Input delegate.</param>
 /// <returns>An F# lambda wrapper.</returns>
 public static FSharpFunc <S, unit> ToFSharpFunc <S>(this Action <S> func)
 {
     return(FSharpFunc.Create(func));
 }
コード例 #4
0
 /// <summary>
 ///     Wraps delegate to an F# function
 /// </summary>
 /// <typeparam name="S">Argument type.</typeparam>
 /// <typeparam name="T">Return type.</typeparam>
 /// <param name="func">Input delegate.</param>
 /// <returns>An F# lambda wrapper.</returns>
 public static FSharpFunc <S, T> ToFSharpFunc <S, T>(this Func <S, T> func)
 {
     return(FSharpFunc.Create(func));
 }
コード例 #5
0
 /// <summary>
 ///     Wraps delegate to an F# function
 /// </summary>
 /// <typeparam name="S1"></typeparam>
 /// <typeparam name="S2"></typeparam>
 /// <typeparam name="S3"></typeparam>
 /// <typeparam name="S4"></typeparam>
 /// <typeparam name="T">Return type.</typeparam>
 /// <param name="func">Input delegate.</param>
 /// <returns>An F# lambda wrapper.</returns>
 public static FSharpFunc <S1, FSharpFunc <S2, FSharpFunc <S3, FSharpFunc <S4, T> > > > ToFSharpFunc <S1, S2, S3, S4, T>(this Func <S1, S2, S3, S4, T> func)
 {
     return(FSharpFunc.Create(func));
 }
コード例 #6
0
ファイル: CloudFlow.cs プロジェクト: vilinski/MBrace.Core
 /// <summary>
 /// Locates the minimum element of the flow by given key.
 /// </summary>
 /// <param name="projection">A function that maps items from the input CloudFlow to comparable keys.</param>
 /// <param name="flow">The input CloudFlow.</param>
 public static Cloud <TSource> MinBy <TSource, TKey>(this CloudFlow <TSource> flow, Func <TSource, TKey> projection)
 {
     return(CloudFlowModule.minBy(FSharpFunc.Create(projection), flow));
 }
コード例 #7
0
ファイル: CloudFlow.cs プロジェクト: vilinski/MBrace.Core
 /// <summary>
 ///     Constructs a CloudFlow from a collection of text files using the given reader.
 /// </summary>
 /// <typeparam name="TSource"></typeparam>
 /// <param name="paths">Cloud file input paths.</param>
 /// <param name="deserializer">A function to transform the contents of a CloudFile to a stream of elements.</param>
 /// <param name="encoding">Text encoding used by the underlying text files.</param>
 /// <param name="sizeThresholdPerCore">Restricts concurrent processing of collection partitions up to specified size per core. Defaults to 256MiB.</param>
 /// <returns>A CloudFlow that performs distributed computation on deserialized cloud file contents.</returns>
 public static CloudFlow <TSource> OfCloudFiles <TSource>(IEnumerable <string> paths, Func <TextReader, IEnumerable <TSource> > deserializer,
                                                          Encoding encoding = null, long?sizeThresholdPerCore = null)
 {
     return(MBrace.Flow.CloudFlow.OfCloudFiles <TSource>(paths, FSharpFunc.Create(deserializer), encoding: Option.FromNullable(encoding),
                                                         sizeThresholdPerCore: Option.FromNullable(sizeThresholdPerCore)));
 }
コード例 #8
0
ファイル: CloudFlow.cs プロジェクト: vilinski/MBrace.Core
 /// <summary>Applies a key-generating function to each element of the input CloudFlow and yields the CloudFlow of the given length, ordered by keys.</summary>
 /// <param name="projection">A function to transform items of the input CloudFlow into comparable keys.</param>
 /// <param name="flow">The input CloudFlow.</param>
 /// <param name="takeCount">The number of elements to return.</param>
 /// <returns>The result CloudFlow.</returns>
 public static CloudFlow <TSource> OrderByDescending <TSource, TKey>(this CloudFlow <TSource> flow, Func <TSource, TKey> projection, int takeCount) where TKey : IComparable <TKey>
 {
     return(CloudFlowModule.sortByDescending(FSharpFunc.Create(projection), takeCount, flow));
 }
コード例 #9
0
ファイル: CloudFlow.cs プロジェクト: vilinski/MBrace.Core
 /// <summary>
 /// Applies a key-generating function to each element of a CloudFlow and return a CloudFlow yielding unique keys and their number of occurrences in the original sequence.
 /// </summary>
 /// <param name="projection">A function that maps items from the input CloudFlow to keys.</param>
 /// <param name="flow">The input CloudFlow.</param>
 public static CloudFlow <Tuple <TKey, long> > CountBy <TSource, TKey>(this CloudFlow <TSource> flow, Func <TSource, TKey> projection)
 {
     return(CloudFlowModule.countBy(FSharpFunc.Create(projection), flow));
 }
コード例 #10
0
ファイル: CloudFlow.cs プロジェクト: vilinski/MBrace.Core
 /// <summary>Applies a function to each element of the CloudFlow, threading an accumulator argument through the computation. If the input function is f and the elements are i0...iN, then this function computes f (... (f s i0)...) iN.</summary>
 /// <param name="folder">A function that updates the state with each element from the CloudFlow.</param>
 /// <param name="combiner">A function that combines partial states into a new state.</param>
 /// <param name="state">A function that produces the initial state.</param>
 /// <param name="flow">The input CloudFlow.</param>
 /// <returns>The final result.</returns>
 public static Cloud <TAccumulate> Aggregate <TSource, TAccumulate>(this CloudFlow <TSource> flow, Func <TAccumulate> state, Func <TAccumulate, TSource, TAccumulate> folder, Func <TAccumulate, TAccumulate, TAccumulate> combiner)
 {
     return(CloudFlowModule.fold <TAccumulate, TSource>(FSharpFunc.Create(folder), FSharpFunc.Create(combiner), FSharpFunc.Create(state), flow));
 }
コード例 #11
0
ファイル: CloudFlow.cs プロジェクト: vilinski/MBrace.Core
 /// <summary>
 ///     Applies a key-generating function to each element of the input flow and yields a flow of unique keys and a sequence of all elements that have each key.
 /// <remarks>
 ///     Note: This combinator may be very expensive; for example if the group sizes are expected to be large.
 ///     If you intend to perform an aggregate operation, such as sum or average,
 ///     you are advised to use CloudFlow.foldBy or CloudFlow.countBy, for much better performance.
 /// </remarks>
 /// </summary>
 /// <param name="projection">A function to transform items of the input flow into comparable keys.</param>
 /// <param name="flow">The input flow.</param>
 /// <returns>A flow of tuples where each tuple contains the unique key and a sequence of all the elements that match the key.</returns>
 public static CloudFlow <KeyValuePair <TKey, IEnumerable <TSource> > > GroupBy <TSource, TKey>(this CloudFlow <TSource> flow, Func <TSource, TKey> projection)
 {
     return(CloudFlowModule
            .groupBy(FSharpFunc.Create(projection), flow)
            .Select(tuple => new KeyValuePair <TKey, IEnumerable <TSource> >(tuple.Item1, tuple.Item2)));
 }
コード例 #12
0
ファイル: CloudFlow.cs プロジェクト: vilinski/MBrace.Core
 /// <summary>Transforms each element of the input CloudFlow to a new flow and flattens its elements.</summary>
 /// <param name="f">A function to transform items from the input CloudFlow.</param>
 /// <param name="flow">The input CloudFlow.</param>
 /// <returns>The result CloudFlow.</returns>
 public static CloudFlow <TResult> SelectMany <TSource, TResult>(this CloudFlow <TSource> flow, Func <TSource, IEnumerable <TResult> > f)
 {
     return(CloudFlowModule.collect <TSource, IEnumerable <TResult>, TResult>(FSharpFunc.Create(f), flow));
 }
コード例 #13
0
ファイル: CloudFlow.cs プロジェクト: vilinski/MBrace.Core
 /// <summary>Filters the elements of the input CloudFlow.</summary>
 /// <param name="predicate">A function to test each source element for a condition.</param>
 /// <param name="flow">The input CloudFlow.</param>
 /// <returns>The result CloudFlow.</returns>
 public static CloudFlow <TSource> Where <TSource>(this CloudFlow <TSource> flow, Func <TSource, bool> predicate)
 {
     return(CloudFlowModule.filter(FSharpFunc.Create(predicate), flow));
 }
コード例 #14
0
ファイル: CloudFlow.cs プロジェクト: vilinski/MBrace.Core
 /// <summary>Transforms each element of the input CloudFlow.</summary>
 /// <param name="f">A function to transform items from the input CloudFlow.</param>
 /// <param name="flow">The input CloudFlow.</param>
 /// <returns>The result CloudFlow.</returns>
 public static CloudFlow <TResult> Select <TSource, TResult>(this CloudFlow <TSource> flow, Func <TSource, TResult> f)
 {
     return(CloudFlowModule.map(FSharpFunc.Create(f), flow));
 }