Deedle


Seq

Namespace: Deedle.Internal

This module contains additional functions for working with sequences. Deedle.Internals is opened, it extends the standard Seq module.

Functions and values

Function or valueDescription
alignAllOrdered collections comparer
Signature: collections:ReadOnlyCollection<'a> [] -> comparer:IComparer<'a> -> 'a [] * (int64 * int64) [] list
Type parameters: 'a

Calls either alignAllOrderedMany or alignAllOrderedFew depending on the number of sequences to be aligned. Performance measurements suggest that 150 is the limit when the implementation using binomial heap is faster.

alignAllOrderedFew seqs comparer
Signature: seqs:ReadOnlyCollection<'T> [] -> comparer:IComparer<'T> -> 'T [] * (int64 * int64) [] list
Type parameters: 'T

Align N ordered sequences of keys (using the specified comparer) This is the same as alignOrdered but for larger number of key sequences. Throws ComparisonFailedException when the comparer fails. (This performs union on the specified sequences)

alignAllOrderedMany seqs comparer
Signature: seqs:ReadOnlyCollection<'T> [] -> comparer:IComparer<'T> -> 'T [] * (int64 * int64) [] list
Type parameters: 'T

Align N ordered sequences of keys (using the specified comparer) This is the same as alignOrdered but for larger number of key sequences. Throws ComparisonFailedException when the comparer fails. (This performs union on the specified sequences)

alignAllUnordered(seqs)
Signature: seqs:ReadOnlyCollection<'T> [] -> 'T [] * (int64 * int64) [] list
Type parameters: 'T

Align N unordered sequences of keys (performs union of the keys)

alignOrdered(...)
Signature: seq1:ReadOnlyCollection<'T> -> seq2:ReadOnlyCollection<'T> -> comparer:IComparer<'T> -> intersectionOnly:bool -> 'T [] * (int64 * int64) [] list
Type parameters: 'T

Align two ordered sequences of keys (using the specified comparer) The resulting relocations are returned as two-element list for symmetry with other functions Throws ComparisonFailedException when the comparer fails.

When intersectionOnly = true, the function only adds keys & relocations for keys that appear in both sequences (otherwise, it performs union)

alignUnordered s1 s2 intersectionOnly
Signature: s1:ReadOnlyCollection<'a> -> s2:ReadOnlyCollection<'a> -> intersectionOnly:bool -> 'a [] * (int64 * int64) [] list
Type parameters: 'a

Align two unordered sequences of keys. Calls either alignUnorderedUnion or alignUnorderedIntersection, based on the intersectionOnly parameter.

alignUnorderedIntersection seq1 seq2
Signature: seq1:ReadOnlyCollection<'T> -> seq2:ReadOnlyCollection<'T> -> 'T [] * (int64 * int64) [] list
Type parameters: 'T

Align two unordered sequences of keys (performs intersection of the keys) The resulting relocations are returned as two-element list for symmetry with other functions

alignUnorderedUnion seq1 seq2
Signature: seq1:ReadOnlyCollection<'T> -> seq2:ReadOnlyCollection<'T> -> 'T [] * (int64 * int64) [] list
Type parameters: 'T

Align two unordered sequences of keys (performs union of the keys) The resulting relocations are returned as two-element list for symmetry with other functions

choosel f input
Signature: f:(int64 -> 'a -> 'b option) -> input:seq<'a> -> seq<'b>
Type parameters: 'a, 'b

Same as Seq.choose but passes 64 bit index (l stands for long) to the function

chunkedWhile f input
Signature: f:('?692951 -> '?692951 -> bool) -> input:seq<'?692951> -> seq<'?692951 []>
Type parameters: '?692951

Generate non-verlapping chunks from the input sequence. A chunk is started at the beginning and then immediately after the end of the previous chunk. To find the end of the chunk, the function calls the provided argument f with the first and the last elements of the chunk as arguments. A chunk ends when f returns false.

chunkedWithBounds size boundary input
Signature: size:int -> boundary:Boundary -> input:seq<'?692955> -> seq<DataSegment<'?692955 []>>
Type parameters: '?692955

Similar to Seq.windowedWithBounds, but generates non-overlapping chunks rather than floating windows. See that function for detailed documentation. The function may iterate over the sequence repeatedly.

chunkRangesWhile f input
Signature: f:('a -> 'a -> bool) -> input:seq<'a> -> seq<int64 * int64>
Type parameters: 'a

Generate non-verlapping chunks from the input sequence. A chunk is started at the beginning and then immediately after the end of the previous chunk. To find the end of the chunk, the function calls the provided argument f with the first and the last elements of the chunk as arguments. A chunk ends when f returns false. The function returns the chunks as pairs of their indices.

chunkRangesWithBounds(...)
Signature: size:int64 -> boundary:Boundary -> length:int64 -> seq<DataSegmentKind * int64 * int64>

Generates addresses of windows in a collection of size 'length'. For example, consider a collection with 7 elements (and indices 0 .. 6) and the requirement to create windows of length 3:

0 1 2 3 4 5 6

When the AtEnding flag is set for boundary:

c c c c c c d

The two chunks marked as 'c' are returned always. The incomplete chunk at the end is returned unless the Skip flag is set for boundary. When the AtBeginning flag is set, the incomplete chunk is (when not Skip) returned at the beginning:

d c c c c c c

The chunks are specified by inclusive indices, so, e.g. the first chunk in the second example above is returned as a pair (0, 0).

getEnumerator(s)
Signature: s:seq<'?692945> -> IEnumerator<'?692945>
Type parameters: '?692945

Calls the GetEnumerator method. Simple function to guide type inference.

headOrNone(input)
Signature: input:seq<'a> -> 'a option
Type parameters: 'a

If the input is non empty, returns Some(head) where head is the first value. Otherwise, returns None.

isSorted data comparer
Signature: data:seq<'T> -> comparer:IComparer<'T> -> bool
Type parameters: 'T

Returns true if the specified sequence is sorted.

lastAndLength(input)
Signature: input:seq<'a> -> 'a * int
Type parameters: 'a

Returns the last element and the length of a sequence (using just a single iteration over the sequence)

lastFew count input
Signature: count:int -> input:seq<'?692943> -> seq<'?692943>
Type parameters: '?692943

Returns the specified number of elements from the end of the sequence Note that this needs to store the specified number of elements in memory and it needs to iterate over the entire sequence.

mapl f input
Signature: f:(int64 -> 'a -> 'b) -> input:seq<'a> -> seq<'b>
Type parameters: 'a, 'b

Same as Seq.map but passes 64 bit index (l stands for long) to the function

range lo hi
Signature: lo:^T -> hi:^T -> IEnumerable<^T>
Type parameters: ^T

A helper function that generates a sequence for the specified range of int or int64 values. This is notably faster than using lo .. hi.

rangeStep lo step hi
Signature: lo:^T -> step:^T -> hi:^T -> IEnumerable<^T>
Type parameters: ^T

A helper function that generates a sequence for the specified range of int or int64 values. This is notably faster than using lo .. step .. hi.

skipAtMost count input
Signature: count:int -> input:seq<'b> -> seq<'b>
Type parameters: 'b

Skip at most the specified number of elements. This is like Seq.skip, but it does not throw when the sequence is shorter.

startAndEnd startCount endCount input
Signature: startCount:int -> endCount:int -> input:seq<'a> -> seq<Choice<'a,unit,'a>>
Type parameters: 'a

Given a sequence, returns startCount number of elements at the beginning of the sequence (wrapped in Choice1Of3) followed by one Choice2Of2() value and then followed by endCount number of elements at the end of the sequence wrapped in Choice3Of3. If the input is shorter than startCount + endCount, then all values are returned and wrapped in Choice1Of3.

structuralEquals s1 s2
Signature: s1:seq<'T> -> s2:seq<'T> -> bool
Type parameters: 'T

Comapre two sequences using the Equals method. Returns true when all their elements are equal and they have the same size.

structuralHash(s)
Signature: s:seq<'T> -> int
Type parameters: 'T

Calculate hash code of a sequence, based on the values

tryFirstAndLast(input)
Signature: input:seq<'a> -> ('a * 'a) option
Type parameters: 'a

Returns the first and the last element from a sequence or 'None' if the sequence is empty

uniqueBy f input
Signature: f:('a -> 'b) -> input:seq<'a> -> 'b
Type parameters: 'a, 'b

If the projection returns the same value for all elements, then it returns the value. Otherwise it throws an exception.

unreduce f start
Signature: f:('a -> 'a) -> start:'a -> seq<'a>
Type parameters: 'a

Generate infinite sequence using the specified function. The initial state is returned as the first element.

windowedWhile f input
Signature: f:('T -> 'T -> bool) -> input:seq<'T> -> seq<'T []>
Type parameters: 'T

Generate floating windows from the input sequence. New floating window is started for each element. To find the end of the window, the function calls the provided argument f with the first and the last elements of the window as arguments. A window ends when f returns false.

windowedWithBounds size boundary input
Signature: size:int -> boundary:Boundary -> input:seq<'T> -> seq<DataSegment<'T []>>
Type parameters: 'T

A version of Seq.windowed that allows specifying more complex boundary behaviour. The boundary argument can specify one of the following options:

  • Boundary.Skip - only full windows are returned (like Seq.windowed)
  • Boundary.AtBeginning - incomplete windows (smaller than the required size) are returned at the beginning.
  • Boundary.AtEnding - incomplete windows are returned at the end.

The result is a sequence of DataSegnebt<T> values, which makes it easy to distinguish between complete and incomplete windows.

windowRangesWhile f input
Signature: f:('T -> 'T -> bool) -> input:seq<'T> -> seq<int64 * int64>
Type parameters: 'T

Generate floating windows from the input sequence. New floating window is started for each element. To find the end of the window, the function calls the provided argument f with the first and the last elements of the window as arguments. A window ends when f returns false. The function returns the windows as pairs of their indices.

windowRangesWithBounds(...)
Signature: size:int64 -> boundary:Boundary -> length:int64 -> seq<DataSegmentKind * int64 * int64>

Generates addresses of chunks in a collection of size 'length'. For example, consider a collection with 7 elements (and indices 0 .. 6) and the requirement to create chunks of length 4:

0 1 2 3 4 5 6

s s s s s s w w w w w w w w w w w w w w w w e e e e e e

The windows 's' are returned when boundary = Boundary.AtBeginning and the windows 'e' are returned when boundary = Boundary.AtEnding. The middle is returned always. The windows are specified by inclusive indices, so, e.g. the first window is returned as a pair (0, 0).

Fork me on GitHub