Home Manual Reference Source

Function

Static Public Summary
public

* compress(iterable: Iterable, selector: Iterable): Iterator

Filters the first input iterable according to truthy and flasy values from a second input iterable.

public

* filter(predicate: Function, iterable: Iterable): IterableIterator

Yields all elements from input iterable that verify a given predicate.

public

* filterfalse(predicate: Function, iterable: Iterable): IterableIterator

Yields all elements from input iterable that do not verify a given predicate.

Static Public

public * compress(iterable: Iterable, selector: Iterable): Iterator source

Filters the first input iterable according to truthy and flasy values from a second input iterable. The ith element of the first input iterable is output if and only if the ith element of the second input iterable is truthy.

Params:

NameTypeAttributeDescription
iterable Iterable

The first input iterable to filter.

selector Iterable

The second input iterable containing the truthy and falsy values.

Return:

Iterator

public * filter(predicate: Function, iterable: Iterable): IterableIterator source

Yields all elements from input iterable that verify a given predicate.

Params:

NameTypeAttributeDescription
predicate Function

A unary function that returns a truthy or falsy value.

iterable Iterable

The input iterable.

Return:

IterableIterator

Example:

// returns [ 1 , 3 , 5 , 7 , 9 ]
list( filter( x => x % 2 , range( 10 ) ) ) ;

public * filterfalse(predicate: Function, iterable: Iterable): IterableIterator source

Yields all elements from input iterable that do not verify a given predicate.

Params:

NameTypeAttributeDescription
predicate Function

A unary function that returns a truthy or falsy value.

iterable Iterable

The input iterable.

Return:

IterableIterator

Example:

// returns [ 0 , 2 , 4 , 6 , 8 ]
list( filter( x => x % 2 , range( 10 ) ) ) ;