FSharpx.Collections


Seq Module

Extensions for F#'s Seq module.

Functions and values

Function or value Description

Seq.asCircular values

Full Usage: Seq.asCircular values

Parameters:
    values : seq<'a>

Returns: seq<'a>

Creates a infinite sequences of the given values

values : seq<'a>
Returns: seq<'a>

Seq.asCircularOnLoop f values

Full Usage: Seq.asCircularOnLoop f values

Parameters:
    f : unit -> unit
    values : seq<'a>

Returns: seq<'a>

Creates a infinite sequences of the given values, executing the given function everytime the given seq is exhausted

f : unit -> unit
values : seq<'a>
Returns: seq<'a>

Seq.asCircularWithBreak values

Full Usage: Seq.asCircularWithBreak values

Parameters:
    values : seq<'a>

Returns: seq<'a option>

Creates a infinite sequences of the given values returning None everytime the given seq is exhausted

values : seq<'a>
Returns: seq<'a option>

Seq.catOptions xs

Full Usage: Seq.catOptions xs

Parameters:
Returns: seq<'a>

The catOptions function takes a list of Options and returns a seq of all the Some values.

xs : seq<Option<'a>>
Returns: seq<'a>

Seq.choice1s xs

Full Usage: Seq.choice1s xs

Parameters:
Returns: seq<'a>

Extracts from a seq of Choice all the Choice1Of2 elements. All the Choice1Of2 elements are extracted in order.

xs : seq<Choice<'a, 'b>>
Returns: seq<'a>

Seq.choice2s xs

Full Usage: Seq.choice2s xs

Parameters:
Returns: seq<'b>

Extracts from a seq of Choice all the Choice2Of2 elements. All the Choice2Of2 elements are extracted in order.

xs : seq<Choice<'a, 'b>>
Returns: seq<'b>

Seq.combine f a b

Full Usage: Seq.combine f a b

Parameters:
    f : 'a -> 'b -> 'c
    a : seq<'a>
    b : seq<'b>

Returns: seq<'c>

Creates a new collection whose elements are the results of applying the given function to the corresponding pairs of elements from the two sequences. Unlike Seq.map2, if one input sequence is shorter than the other then the remaining elements of the longer sequence are not ignored, they are yielded at the end of the resulting sequence.

f : 'a -> 'b -> 'c
a : seq<'a>
b : seq<'b>
Returns: seq<'c>

Seq.cons x xs

Full Usage: Seq.cons x xs

Parameters:
    x : 'a
    xs : seq<'a>

Returns: seq<'a>

Prepends `x` to the seq `xs`

x : 'a
xs : seq<'a>
Returns: seq<'a>

Seq.contract n source

Full Usage: Seq.contract n source

Parameters:
    n : int
    source : seq<'a>

Returns: seq<'a>

Contracts a seq selecting every n values

n : int
source : seq<'a>
Returns: seq<'a>

Seq.equalsWith eq xs ys

Full Usage: Seq.equalsWith eq xs ys

Parameters:
    eq : 'a -> 'a -> bool
    xs : seq<'a>
    ys : seq<'a>

Returns: bool

Compares two sequences for equality using the given comparison function, element by element.

eq : 'a -> 'a -> bool
xs : seq<'a>
ys : seq<'a>
Returns: bool

Seq.groupNeighboursBy projection source

Full Usage: Seq.groupNeighboursBy projection source

Parameters:
    projection : 'T -> 'Key
    source : seq<'T>

Returns: seq<'Key * seq<'T>>

Applies a key-generating function to each element of a sequence and yields a sequence of unique keys and a sequence of all elements that have each key. This function groups together only neighbouring elements in the seq.

projection : 'T -> 'Key
source : seq<'T>
Returns: seq<'Key * seq<'T>>

Seq.grow n

Full Usage: Seq.grow n

Parameters:
    n : int

Returns: seq<'a> -> seq<'a>

Replicates each element in the seq n-times

n : int
Returns: seq<'a> -> seq<'a>

Seq.index a

Full Usage: Seq.index a

Parameters:
    a : seq<'a> -

Returns: seq<int * 'a>

Adds an index to a sequence

a : seq<'a>

Returns: seq<int * 'a>

Seq.intersperse sep list

Full Usage: Seq.intersperse sep list

Parameters:
    sep : 'a
    list : seq<'a>

Returns: seq<'a>
sep : 'a
list : seq<'a>
Returns: seq<'a>

Seq.iterBreak f seq

Full Usage: Seq.iterBreak f seq

Parameters:
    f : 'T -> bool
    seq : seq<'T>

Will iterate the current sequence until the given predicate is satisfied

f : 'T -> bool
seq : seq<'T>

Seq.lift2 f l1 l2

Full Usage: Seq.lift2 f l1 l2

Parameters:
    f : 'a -> 'b -> 'c
    l1 : seq<'a>
    l2 : seq<'b>

Returns: seq<'c>
f : 'a -> 'b -> 'c
l1 : seq<'a>
l2 : seq<'b>
Returns: seq<'c>

Seq.ofStreamByByte stream

Full Usage: Seq.ofStreamByByte stream

Parameters:
Returns: seq<int>

Converts a Stream into a sequence of bytes

stream : Stream
Returns: seq<int>

Seq.ofStreamByChunk chunkSize stream

Full Usage: Seq.ofStreamByChunk chunkSize stream

Parameters:
    chunkSize : int
    stream : Stream

Returns: seq<byte[]>

Converts a stream into a seq of byte[] where the array is of the length given Note: the last chunk maybe less than the given chunk size

chunkSize : int
stream : Stream
Returns: seq<byte[]>

Seq.ofStreamReader streamReader

Full Usage: Seq.ofStreamReader streamReader

Parameters:
Returns: seq<string>

Converts a streamReader into a seq yielding on each line

streamReader : StreamReader
Returns: seq<string>

Seq.page page pageSize source

Full Usage: Seq.page page pageSize source

Parameters:
    page : int
    pageSize : int
    source : seq<'a>

Returns: seq<'a>

Pages the underlying sequence

page : int
pageSize : int
source : seq<'a>
Returns: seq<'a>

Seq.partitionChoices xs

Full Usage: Seq.partitionChoices xs

Parameters:
Returns: seq<'a> * seq<'b>

Partitions a seq of Choice into two seqs. All the Choice1Of2 elements are extracted, in order, to the first component of the output. Similarly the Choice2Of2 elements are extracted to the second component of the output.

xs : seq<Choice<'a, 'b>>
Returns: seq<'a> * seq<'b>

Seq.prependToAll sep list

Full Usage: Seq.prependToAll sep list

Parameters:
    sep : 'a
    list : seq<'a>

Returns: seq<'a>
sep : 'a
list : seq<'a>
Returns: seq<'a>

Seq.repeat a

Full Usage: Seq.repeat a

Parameters:
    a : 'a

Returns: seq<'a>

Creates an infinite sequence of the given value

a : 'a
Returns: seq<'a>

Seq.skipNoFail count source

Full Usage: Seq.skipNoFail count source

Parameters:
    count : int
    source : seq<'a>

Returns: IEnumerable<'a>

The same as Seq.skip except it returns empty if the sequence is empty or does not have enough elements. Alias for Enumerable.Skip

count : int
source : seq<'a>
Returns: IEnumerable<'a>

Seq.span predicate source

Full Usage: Seq.span predicate source

Parameters:
    predicate : 'a -> bool
    source : seq<'a>

Returns: seq<'a> * seq<'a>

Splits a sequences up to the point where the predicate holds

predicate : 'a -> bool
source : seq<'a>
Returns: seq<'a> * seq<'a>

Seq.splitAt n seq

Full Usage: Seq.splitAt n seq

Parameters:
    n : int
    seq : seq<'a>

Returns: seq<'a> * seq<'a>

Splits a sequences at the given index

n : int
seq : seq<'a>
Returns: seq<'a> * seq<'a>

Seq.tail source

Full Usage: Seq.tail source

Parameters:
    source : seq<'a>

Returns: seq<'a>
source : seq<'a>
Returns: seq<'a>

Seq.tailNoFail source

Full Usage: Seq.tailNoFail source

Parameters:
    source : seq<'a>

Returns: seq<'a>
source : seq<'a>
Returns: seq<'a>

Seq.tryAverage seq

Full Usage: Seq.tryAverage seq

Parameters:
    seq : seq<^a>

Returns: ^a option

The same as Seq.average except will return None if the seq is empty

seq : seq<^a>
Returns: ^a option

Seq.tryFindWithIndex pred l

Full Usage: Seq.tryFindWithIndex pred l

Parameters:
    pred : 'a -> bool - Predicate
    l : seq<'a> - Sequence

Returns: (int * 'a) option

Returns the first element (with its index) for which the given function returns true. Return None if no such element exists.

pred : 'a -> bool

Predicate

l : seq<'a>

Sequence

Returns: (int * 'a) option

Seq.tryHead source

Full Usage: Seq.tryHead source

Parameters:
    source : seq<'a>

Returns: 'a option

A safe version of seq head

source : seq<'a>
Returns: 'a option

Seq.tryNth index source

Full Usage: Seq.tryNth index source

Parameters:
    index : int
    source : seq<'a>

Returns: 'a option

The same as Seq.nth except returns None if the sequence is empty or does not have enough elements

index : int
source : seq<'a>
Returns: 'a option

Seq.unCons s

Full Usage: Seq.unCons s

Parameters:
    s : seq<'a>

Returns: ('a * seq<'a>) option

Returns the head and tail of the seq. If the seq is empty, returns `None`.

s : seq<'a>
Returns: ('a * seq<'a>) option