Upcoming SlideShare
×

# Object Range

388
-1

Published on

Introduction to javascript

0 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

• Be the first to like this

Views
Total Views
388
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
5
0
Likes
0
Embeds 0
No embeds

No notes for slide

### Object Range

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

Clipping is a handy way to collect important slides you want to go back to later.