time-to-botec

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

README.md (3694B)


      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 # iterCompositesSeq
     22 
     23 > Create an iterator which generates a sequence of [composite numbers][oeis-a002808].
     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 iterCompositesSeq = require( '@stdlib/math/iter/sequences/composites' );
     41 ```
     42 
     43 #### iterCompositesSeq( \[options] )
     44 
     45 Returns an iterator which generates a sequence of composite numbers.
     46 
     47 ```javascript
     48 var it = iterCompositesSeq();
     49 // returns <Object>
     50 
     51 var v = it.next().value;
     52 // returns 4
     53 
     54 v = it.next().value;
     55 // returns 6
     56 
     57 v = it.next().value;
     58 // returns 8
     59 
     60 v = it.next().value;
     61 // returns 9
     62 
     63 v = it.next().value;
     64 // returns 10
     65 
     66 // ...
     67 ```
     68 
     69 The returned iterator protocol-compliant object has the following properties:
     70 
     71 -   **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.
     72 -   **return**: function which closes an iterator and returns a single (optional) argument in an iterator protocol-compliant object.
     73 
     74 The function supports the following `options`:
     75 
     76 -   **iter**: number of iterations. Default: `1e308`.
     77 
     78 By default, the function returns an infinite iterator (i.e., an iterator which never ends). To adjust the number of iterations, set the `iter` option.
     79 
     80 ```javascript
     81 var opts = {
     82     'iter': 2
     83 };
     84 var it = iterCompositesSeq( opts );
     85 // returns <Object>
     86 
     87 var v = it.next().value;
     88 // returns 4
     89 
     90 v = it.next().value;
     91 // returns 6
     92 
     93 var bool = it.next().done;
     94 // returns true
     95 ```
     96 
     97 </section>
     98 
     99 <!-- /.usage -->
    100 
    101 <!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
    102 
    103 <section class="notes">
    104 
    105 ## Notes
    106 
    107 -   If an environment supports `Symbol.iterator`, the returned iterator is iterable.
    108 
    109 </section>
    110 
    111 <!-- /.notes -->
    112 
    113 <!-- Package usage examples. -->
    114 
    115 <section class="examples">
    116 
    117 ## Examples
    118 
    119 <!-- eslint no-undef: "error" -->
    120 
    121 ```javascript
    122 var iterCompositesSeq = require( '@stdlib/math/iter/sequences/composites' );
    123 
    124 // Create an iterator:
    125 var opts = {
    126     'iter': 100
    127 };
    128 var it = iterCompositesSeq( opts );
    129 
    130 // Perform manual iteration...
    131 var v;
    132 while ( true ) {
    133     v = it.next();
    134     if ( v.done ) {
    135         break;
    136     }
    137     console.log( v.value );
    138 }
    139 ```
    140 
    141 </section>
    142 
    143 <!-- /.examples -->
    144 
    145 <!-- 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. -->
    146 
    147 <section class="references">
    148 
    149 </section>
    150 
    151 <!-- /.references -->
    152 
    153 <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
    154 
    155 <section class="links">
    156 
    157 [oeis-a002808]: https://oeis.org/A002808
    158 
    159 </section>
    160 
    161 <!-- /.links -->