FSharp.Collections.ParallelSeq


F# Parallel Sequences

This package provides an F#-style API for the parallel operations on sequences from the System.Linq.ParallelEnumerable class in .NET. The API is akin to F# operations on sequences.

Example

This example demonstrates the use of a function defined in this package.

#r "FSharp.Collections.ParallelSeq.dll"

open FSharp.Collections.ParallelSeq

let nums = [| 1..500000 |]

let isPrime n =
    let upperBound = int (sqrt (float n))

    let hasDivisor =
        [ 2..upperBound ]
        |> List.exists (fun i -> n % i = 0)

    not hasDivisor

let finalDigitOfPrimes =
    nums
    |> PSeq.filter isPrime
    |> PSeq.groupBy (fun i -> i % 10)
    |> PSeq.map (fun (k, vs) -> (k, Seq.length vs))
    |> PSeq.toArray

Samples & documentation

Contributing and copyright

The project is hosted on GitHub where you can report issues, fork the project and submit pull requests. If you're adding new public API, please also consider adding samples that can be turned into a documentation. You might also want to read library design notes to understand how it works.

The library is available under the Apache 2.0 license, which allows modification and redistribution for both commercial and non-commercial purposes. For more information see the License file in the GitHub repository.

Multiple items
namespace FSharp

--------------------
namespace Microsoft.FSharp
Multiple items
namespace FSharp.Collections

--------------------
namespace Microsoft.FSharp.Collections
namespace FSharp.Collections.ParallelSeq
val nums : int []
val isPrime : n:int -> bool
val n : int
val upperBound : int
Multiple items
val int : value:'T -> int (requires member op_Explicit)
<summary>Converts the argument to signed 32-bit integer. This is a direct conversion for all primitive numeric types. For strings, the input is converted using <c>Int32.Parse()</c> with InvariantCulture settings. Otherwise the operation requires an appropriate static conversion method on the input type.</summary>
<param name="value">The input value.</param>
<returns>The converted int</returns>


--------------------
[<Struct>] type int = int32
<summary>An abbreviation for the CLI type <see cref="T:System.Int32" />.</summary>
<category>Basic Types</category>


--------------------
type int<'Measure> = int
<summary>The type of 32-bit signed integer numbers, annotated with a unit of measure. The unit of measure is erased in compiled code and when values of this type are analyzed using reflection. The type is representationally equivalent to <see cref="T:System.Int32" />.</summary>
<category>Basic Types with Units of Measure</category>
val sqrt : value:'T -> 'U (requires member Sqrt)
<summary>Square root of the given number</summary>
<param name="value">The input value.</param>
<returns>The square root of the input.</returns>
Multiple items
val float : value:'T -> float (requires member op_Explicit)
<summary>Converts the argument to 64-bit float. This is a direct conversion for all primitive numeric types. For strings, the input is converted using <c>Double.Parse()</c> with InvariantCulture settings. Otherwise the operation requires an appropriate static conversion method on the input type.</summary>
<param name="value">The input value.</param>
<returns>The converted float</returns>


--------------------
[<Struct>] type float = System.Double
<summary>An abbreviation for the CLI type <see cref="T:System.Double" />.</summary>
<category>Basic Types</category>


--------------------
type float<'Measure> = float
<summary>The type of double-precision floating point numbers, annotated with a unit of measure. The unit of measure is erased in compiled code and when values of this type are analyzed using reflection. The type is representationally equivalent to <see cref="T:System.Double" />.</summary>
<category index="6">Basic Types with Units of Measure</category>
val hasDivisor : bool
Multiple items
module List from Microsoft.FSharp.Collections
<summary>Contains operations for working with values of type <see cref="T:Microsoft.FSharp.Collections.list`1" />.</summary>
<namespacedoc><summary>Operations for collections such as lists, arrays, sets, maps and sequences. See also <a href="https://docs.microsoft.com/dotnet/fsharp/language-reference/fsharp-collection-types">F# Collection Types</a> in the F# Language Guide. </summary></namespacedoc>


--------------------
type List<'T> = | ( [] ) | ( :: ) of Head: 'T * Tail: 'T list interface IReadOnlyList<'T> interface IReadOnlyCollection<'T> interface IEnumerable interface IEnumerable<'T> member GetReverseIndex : rank:int * offset:int -> int member GetSlice : startIndex:int option * endIndex:int option -> 'T list static member Cons : head:'T * tail:'T list -> 'T list member Head : 'T member IsEmpty : bool member Item : index:int -> 'T with get ...
<summary>The type of immutable singly-linked lists.</summary>
<remarks>Use the constructors <c>[]</c> and <c>::</c> (infix) to create values of this type, or the notation <c>[1;2;3]</c>. Use the values in the <c>List</c> module to manipulate values of this type, or pattern match against the values directly. </remarks>
<exclude />
val exists : predicate:('T -> bool) -> list:'T list -> bool
<summary>Tests if any element of the list satisfies the given predicate.</summary>
<remarks>The predicate is applied to the elements of the input list. If any application returns true then the overall result is true and no further elements are tested. Otherwise, false is returned.</remarks>
<param name="predicate">The function to test the input elements.</param>
<param name="list">The input list.</param>
<returns>True if any element satisfies the predicate.</returns>
val i : int
val not : value:bool -> bool
<summary>Negate a logical value. Not True equals False and not False equals True</summary>
<param name="value">The value to negate.</param>
<returns>The result of the negation.</returns>
val finalDigitOfPrimes : (int * int) array
module PSeq from FSharp.Collections.ParallelSeq
<summary>Parallel operations on IEnumerables.</summary>
val filter : predicate:('T -> bool) -> source:seq<'T> -> pseq<'T>
<summary>Operates in parallel, using System.Linq.Parallel. Returns a new collection containing only the elements of the collection for which the given predicate returns "true".</summary>
<remarks>The returned sequence may be passed between threads safely. However, individual IEnumerator values generated from the returned sequence should not be accessed concurrently. Remember sequence is lazy, effects are delayed until it is enumerated.</remarks>
<param name="predicate">A function to test whether each item in the input sequence should be included in the output.</param>
<param name="source">The input sequence.</param>
<returns>The result sequence.</returns>
<exception cref="System.ArgumentNullException">Thrown when the input sequence is null.</exception>
val groupBy : projection:('T -> 'Key) -> source:seq<'T> -> pseq<'Key * seq<'T>> (requires equality)
<summary>Operates in parallel, using System.Linq.Parallel. Applies a key-generating function to each element of a sequence and yields a sequence of unique keys. Each unique key has also contains a sequence of all elements that match to this key.</summary>
<remarks>This function returns a sequence that digests the whole initial sequence as soon as that sequence is iterated. As a result this function should not be used with large or infinite sequences. The function makes no assumption on the ordering of the original sequence.</remarks>
<param name="projection">A function that transforms an element of the sequence into a comparable key.</param>
<param name="source">The input sequence.</param>
<returns>The result sequence.</returns>
val map : mapping:('T -> 'U) -> source:seq<'T> -> pseq<'U>
<summary>Operates in parallel, using System.Linq.Parallel. Builds a new collection whose elements are the results of applying the given function to each of the elements of the collection. The given function will be applied as elements are demanded using the <c>MoveNext</c> method on enumerators retrieved from the object.</summary>
<remarks>The returned sequence may be passed between threads safely. However, individual IEnumerator values generated from the returned sequence should not be accessed concurrently.</remarks>
<param name="mapping">A function to transform items from the input sequence.</param>
<param name="source">The input sequence.</param>
<returns>The result sequence.</returns>
<exception cref="System.ArgumentNullException">Thrown when the input sequence is null.</exception>
val k : int
val vs : seq<int>
module Seq from Microsoft.FSharp.Collections
<summary>Contains operations for working with values of type <see cref="T:Microsoft.FSharp.Collections.seq`1" />.</summary>
val length : source:seq<'T> -> int
<summary>Returns the length of the sequence</summary>
<param name="source">The input sequence.</param>
<returns>The length of the sequence.</returns>
<exception cref="T:System.ArgumentNullException">Thrown when the input sequence is null.</exception>
val toArray : source:seq<'T> -> 'T array
<summary>Operates in parallel, using System.Linq.Parallel. Builds an array from the given collection.</summary>
<param name="source">The input sequence.</param>
<returns>The result sequence.</returns>
<exception cref="System.ArgumentNullException">Thrown when the input sequence is null.</exception>