Home Manual Reference Source

Function

Static Public Summary
public

* singletonUnderUnaryOperator(operator: Function, start: Object): Iterator

this function is experimental. Should handle multiple d-ary operators and an arbitrary cardinality countable set in the future. An actual closure function would keep track of encountered elements to stop when all elements have been found. We can have multiple low-level function that enumerate candidates, and a helper function that constructs a new set out of a combination of those. Note that the arity of a JavaScript function can be retrieved through the `length` property.

Computes the closure of a unary operator, starting from a single element.

Static Public

public * singletonUnderUnaryOperator(operator: Function, start: Object): Iterator source

import singletonUnderUnaryOperator from '@set-theory/closure/src/singletonUnderUnaryOperator.js'
this function is experimental. Should handle multiple d-ary operators and an arbitrary cardinality countable set in the future. An actual closure function would keep track of encountered elements to stop when all elements have been found. We can have multiple low-level function that enumerate candidates, and a helper function that constructs a new set out of a combination of those. Note that the arity of a JavaScript function can be retrieved through the `length` property.

Computes the closure of a unary operator, starting from a single element.

Params:

NameTypeAttributeDescription
operator Function

The operator.

start Object

The starting element.

Return:

Iterator

Iterator over the closure.

Example:

singletonUnderUnaryOperator( x => x + 1 , 0 ) ; // 0 1 2 3 ...
singletonUnderUnaryOperator( x => x * 2 , 1 ) ; // 1 2 4 8 ...