Home Manual Reference Source

Function

Static Public Summary
public

* by(iterable: Iterable, n: Number): Iterator

Yields elements of the input iterable by grouping them into tuples of a given size.

public

* group(key: Function, iterable: Iterable): Iterator

Yields elements of the input iterable by grouping them into tuples consecutive elements from the same equivalence class.

Static Public

public * by(iterable: Iterable, n: Number): Iterator source

Yields elements of the input iterable by grouping them into tuples of a given size.

Params:

NameTypeAttributeDescription
iterable Iterable

The input iterable.

n Number

The size of the yielded tuples.

Return:

Iterator

public * group(key: Function, iterable: Iterable): Iterator source

Yields elements of the input iterable by grouping them into tuples consecutive elements from the same equivalence class.

Params:

NameTypeAttributeDescription
key Function

The function used to determine the equivalence class of an element.

iterable Iterable

The input iterable.

Return:

Iterator

Example:

// A B C D A B
list( map( ( [ k , g ] ) => k , group( x => x , 'AAAABBBCCDAABBB' ) ) )
// AAAA BBB CC D
list( map( ( [ k , g ] ) => list( g ) , group( x => x , 'AAAABBBCCD' ) ) )