fsprojects/FSharpx.Collections


Seq

Namespace: FSharpx.Collections

Extensions for F#'s Seq module.

Functions and values

Function or valueDescription
asCircular values
Signature: values:seq<'?8818> -> seq<'?8818>
Type parameters: '?8818

Creates a infinite sequences of the given values

asCircularOnLoop f values
Signature: f:(unit -> unit) -> values:seq<'?8820> -> seq<'?8820>
Type parameters: '?8820

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

asCircularWithBreak values
Signature: values:seq<'?8822> -> seq<'?8822 option>
Type parameters: '?8822

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

catOptions xs
Signature: xs:seq<Option<'a>> -> seq<'?8851 option> -> seq<'?8851>
Type parameters: 'a, '?8851

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

choice1s xs
Signature: xs:seq<Choice<'?8853,'?8854>> -> seq<'?8853>
Type parameters: '?8853, '?8854

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

choice2s xs
Signature: xs:seq<Choice<'?8856,'?8857>> -> seq<'?8857>
Type parameters: '?8856, '?8857

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

combine f a b
Signature: f:('?8838 -> '?8839 -> '?8840) -> a:seq<'?8838> -> b:seq<'?8839> -> seq<'?8840>
Type parameters: '?8838, '?8839, '?8840

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.

cons x xs
Signature: x:'?8792 -> xs:seq<'?8792> -> seq<'?8792>
Type parameters: '?8792

Prepends x to the seq xs

contract n source
Signature: n:int -> source:seq<'?8836> -> seq<'?8836>
Type parameters: '?8836

Contracts a seq selecting every n values

equalsWith eq xs ys
Signature: eq:('?8862 -> '?8862 -> bool) -> xs:seq<'?8862> -> ys:seq<'?8862> -> bool
Type parameters: '?8862

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

groupNeighboursBy projection source
Signature: projection:('T -> 'Key) -> source:seq<'T> -> seq<'Key * seq<'T>>
Type parameters: 'T, 'Key

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.

grow n
Signature: n:int -> seq<'?8842> -> seq<'?8842>
Type parameters: '?8842

Replicates each element in the seq n-times

index a
Signature: a:seq<'?8796> -> seq<int * '?8796>
Type parameters: '?8796

Adds an index to a sequence

intersperse sep list
Signature: sep:'a -> list:seq<'a> -> seq<'a>
Type parameters: 'a
iterBreak f seq
Signature: f:('T -> bool) -> seq:seq<'T> -> unit
Type parameters: 'T

Will iterate the current sequence until the given predicate is statisfied

lift2 f l1 l2
Signature: f:('?8800 -> '?8801 -> '?8802) -> l1:seq<'?8800> -> l2:seq<'?8801> -> seq<'?8802>
Type parameters: '?8800, '?8801, '?8802
ofStreamByByte stream
Signature: stream:Stream -> seq<int>

Converts a Stream into a sequence of bytes

ofStreamByChunk chunkSize stream
Signature: chunkSize:int -> stream:Stream -> 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

ofStreamReader streamReader
Signature: streamReader:StreamReader -> seq<string>

Converts a streamReader into a seq yielding on each line

page page pageSize source
Signature: page:int -> pageSize:int -> source:seq<'?8844> -> seq<'?8844>
Type parameters: '?8844

Pages the underlying sequence

partitionChoices xs
Signature: xs:seq<Choice<'a,'b>> -> seq<'a> * seq<'b>
Type parameters: 'a, '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.

prependToAll sep list
Signature: sep:'?8846 -> list:seq<'?8846> -> seq<'?8846>
Type parameters: '?8846
repeat a
Signature: a:'?8834 -> seq<'?8834>
Type parameters: '?8834

Creates an infinite sequence of the given value

skipNoFail count source
Signature: count:int -> source:seq<'?8832> -> IEnumerable<'?8832>
Type parameters: '?8832

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

span predicate source
Signature: predicate:('?8810 -> bool) -> source:seq<'?8810> -> seq<'?8810> * seq<'?8810>
Type parameters: '?8810

Splits a sequences up to the point where the predicate holds

splitAt n seq
Signature: n:int -> seq:seq<'?8808> -> seq<'?8808> * seq<'?8808>
Type parameters: '?8808

Splits a sequences at the given index

tail source
Signature: source:seq<'?8826> -> seq<'?8826>
Type parameters: '?8826
tailNoFail source
Signature: source:seq<'?8828> -> seq<'?8828>
Type parameters: '?8828
tryAverage seq
Signature: seq:seq<^a> -> ^a option
Type parameters: ^a

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

tryFindWithIndex pred l
Signature: pred:('?8798 -> bool) -> l:seq<'?8798> -> (int * '?8798) option
Type parameters: '?8798

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

tryHead source
Signature: source:seq<'?8824> -> '?8824 option
Type parameters: '?8824

A safe version of seq head

tryNth index source
Signature: index:int -> source:seq<'?8830> -> '?8830 option
Type parameters: '?8830

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

unCons s
Signature: s:seq<'?8794> -> ('?8794 * seq<'?8794>) option
Type parameters: '?8794

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

Fork me on GitHub