MultiRangeObject

class MultiRangeObject(arg, rangeObject)

Range objects are vanilla ES objects used to describe value range sets for use by compute.for(). Calculations made to derive the set of numbers in a range are carried out with BigNumber, eg. arbitrary-precision, support. The numbers Infinity and -Infinity are not supported, and the API does not differentiate between +0 and -0.

A multi-range object contains many {@link RangeObject}s. They are iterated over with the fastest moving index going over the right-most range object in array order. Each element of a multi range is a tuple of values from constituent ranges.

Arguments
  • arg (RangeObject|Array.<RangeObject>|object()) – First range object, or array of range objects, or object with ranges key containing an array of range objects.

  • rangeObject (RangeObject()) – If first argument is a RangeObject, subsquent arguments are range objects too.

Examples:

r0 = new RangeObject(1,2)
r1 = new RangeObject(1,3)
mro = new MultiRangeObject(r0, r1)
mro.toArray()
// [ [ 1, 1 ], [ 1, 2 ], [ 1, 3 ], [ 2, 1 ], [ 2, 2 ], [ 2, 3 ] ]

Methods

nthValue

MultiRangeObject.nthValue(n)

Returns a tuple of values from the ranges given by this multi range object.

Arguments
  • n (number()) – index of multi-range tuple to return

Examples:

r0 = new RangeObject(1,2)
r1 = new RangeObject(1,3)
mro = new MultiRangeObject(r0, r1)
mro.toArray()
// [ [ 1, 1 ], [ 1, 2 ], [ 1, 3 ], [ 2, 1 ], [ 2, 2 ], [ 2, 3 ] ]
mro.nthValue(2)
// [ 1, 3 ]

toString

MultiRangeObject.toString()

Create string representation of this MultiRangeObject

Examples:

"[object MultiRangeObject ' + this.ranges.length + ']"

toObject

MultiRangeObject.toObject()

Create object literal with ranges property containing array of range objects.