time-to-botec

Benchmark sampling in different programming languages
Log | Files | Refs | README

README.md (3723B)


      1 <!--
      2 
      3 @license Apache-2.0
      4 
      5 Copyright (c) 2020 The Stdlib Authors.
      6 
      7 Licensed under the Apache License, Version 2.0 (the "License");
      8 you may not use this file except in compliance with the License.
      9 You may obtain a copy of the License at
     10 
     11    http://www.apache.org/licenses/LICENSE-2.0
     12 
     13 Unless required by applicable law or agreed to in writing, software
     14 distributed under the License is distributed on an "AS IS" BASIS,
     15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     16 See the License for the specific language governing permissions and
     17 limitations under the License.
     18 
     19 -->
     20 
     21 # iterNegativeIntegersSeq
     22 
     23 > Create an iterator which generates a [negative integer sequence][oeis-a001478].
     24 
     25 <!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
     26 
     27 <section class="intro">
     28 
     29 </section>
     30 
     31 <!-- /.intro -->
     32 
     33 <!-- Package usage documentation. -->
     34 
     35 <section class="usage">
     36 
     37 ## Usage
     38 
     39 ```javascript
     40 var iterNegativeIntegersSeq = require( '@stdlib/math/iter/sequences/negative-integers' );
     41 ```
     42 
     43 #### iterNegativeIntegersSeq( \[options] )
     44 
     45 Returns an iterator which generates a negative integer sequence.
     46 
     47 ```javascript
     48 var it = iterNegativeIntegersSeq();
     49 // returns <Object>
     50 
     51 var v = it.next().value;
     52 // returns -1
     53 
     54 v = it.next().value;
     55 // returns -2
     56 
     57 v = it.next().value;
     58 // returns -3
     59 
     60 // ...
     61 ```
     62 
     63 The returned iterator protocol-compliant object has the following properties:
     64 
     65 -   **next**: function which returns an iterator protocol-compliant object containing the next iterated value (if one exists) assigned to a `value` property and a `done` property having a `boolean` value indicating whether the iterator is finished.
     66 -   **return**: function which closes an iterator and returns a single (optional) argument in an iterator protocol-compliant object.
     67 
     68 The function supports the following `options`:
     69 
     70 -   **iter**: number of iterations. Default: `9007199254740991`.
     71 
     72 By default, the function returns a finite iterator to avoid exceeding the maximum safe double-precision floating-point integer. To adjust the number of iterations, set the `iter` option.
     73 
     74 ```javascript
     75 var opts = {
     76     'iter': 2
     77 };
     78 var it = iterNegativeIntegersSeq( opts );
     79 // returns <Object>
     80 
     81 var v = it.next().value;
     82 // returns -1
     83 
     84 v = it.next().value;
     85 // returns -2
     86 
     87 var bool = it.next().done;
     88 // returns true
     89 ```
     90 
     91 </section>
     92 
     93 <!-- /.usage -->
     94 
     95 <!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
     96 
     97 <section class="notes">
     98 
     99 ## Notes
    100 
    101 -   If an environment supports `Symbol.iterator`, the returned iterator is iterable.
    102 
    103 </section>
    104 
    105 <!-- /.notes -->
    106 
    107 <!-- Package usage examples. -->
    108 
    109 <section class="examples">
    110 
    111 ## Examples
    112 
    113 <!-- eslint no-undef: "error" -->
    114 
    115 ```javascript
    116 var iterNegativeIntegersSeq = require( '@stdlib/math/iter/sequences/negative-integers' );
    117 
    118 // Create an iterator:
    119 var opts = {
    120     'iter': 100
    121 };
    122 var it = iterNegativeIntegersSeq( opts );
    123 
    124 // Perform manual iteration...
    125 var v;
    126 while ( true ) {
    127     v = it.next();
    128     if ( v.done ) {
    129         break;
    130     }
    131     console.log( v.value );
    132 }
    133 ```
    134 
    135 </section>
    136 
    137 <!-- /.examples -->
    138 
    139 <!-- Section to include cited references. If references are included, add a horizontal rule *before* the section. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
    140 
    141 <section class="references">
    142 
    143 </section>
    144 
    145 <!-- /.references -->
    146 
    147 <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
    148 
    149 <section class="links">
    150 
    151 [oeis-a001478]: https://oeis.org/A001478
    152 
    153 </section>
    154 
    155 <!-- /.links -->