Object Range
- 2. ObjectRange Ranges represent an interval of values. The value type just needs to be “compatible,” include(value) -> Boolean Determines whether the value is included in the range This assumes the values in the range have a valid strict weak ordering (have valid semantics for the < operator). ObjectRange mixes in Enumerable, which makes ranges very versatile. ObjectRange does provide a constructor, the preferred way to obtain a range is to use the $R utility function, This method overrides the default version of include, and is way more efficient it uses a maximum of two comparisons
- 3. ObjectRange Examples; 1)$A($R( 1 , 5 )).join( ', ' ) // -> '1, 2, 3, 4, 5' 2) 2) $R( 1 , 5 ).zip([ 'one' , 'two' , 'three' , 'four' , 'five' ], function (tuple) { return tuple.join( ' = ' ); }) // > ['1 = one', '2 = two', '3 = three', '4 = four', '5 = five'] 3)$A($R( 'a' , 'e' )) // -> ['a', 'b', 'c', 'd', 'e'], no surprise there
- 4. ObjectRange Examples; 1)$R( 1 , 10 ).include( 5 ) // -> true 2)$R( 'a' , 'h' ).include( 'x' ) // -> false 3)$R( 1 , 10 ).include( 10 ) // -> true 4)$R( 1 , 10 , true ).include( 10 ) // -> false