Skip to content

Commit 86d4ec0

Browse files
feat(iter/cartesian-square): add README.md
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent 81e0806 commit 86d4ec0

1 file changed

Lines changed: 154 additions & 0 deletions

File tree

  • lib/node_modules/@stdlib/iter/cartesian-square
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
<!--
2+
3+
@license Apache-2.0
4+
5+
Copyright (c) 2026 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+
# iterCartesianSquare
22+
23+
> Create an [iterator][mdn-iterator-protocol] which iteratively computes the Cartesian square.
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 iterCartesianSquare = require( '@stdlib/iter/cartesian-square' );
41+
```
42+
43+
#### iterCartesianSquare( x )
44+
45+
Returns an [iterator][mdn-iterator-protocol] of the Cartesian square.
46+
47+
```javascript
48+
var x = [ 1, 2 ];
49+
50+
var iter = iterCartesianSquare( x );
51+
// returns <Object>
52+
53+
var v = iter.next().value;
54+
// returns [ 1, 1 ]
55+
56+
v = iter.next().value;
57+
// returns [ 1, 2 ]
58+
59+
v = iter.next().value;
60+
// returns [ 2, 1 ]
61+
62+
// ...
63+
```
64+
65+
The returned [iterator][mdn-iterator-protocol] protocol-compliant object has the following properties:
66+
67+
- **next**: function which returns an [iterator][mdn-iterator-protocol] 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][mdn-iterator-protocol] is finished.
68+
- **return**: function which closes an [iterator][mdn-iterator-protocol] and returns a single (optional) argument in an [iterator][mdn-iterator-protocol] protocol-compliant object.
69+
70+
</section>
71+
72+
<!-- /.usage -->
73+
74+
<!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
75+
76+
<section class="notes">
77+
78+
## Notes
79+
80+
- If an environment supports `Symbol.iterator` **and** a provided [iterator][mdn-iterator-protocol] is iterable, the returned [iterator][mdn-iterator-protocol] is iterable.
81+
82+
</section>
83+
84+
<!-- /.notes -->
85+
86+
<!-- Package usage examples. -->
87+
88+
<section class="examples">
89+
90+
## Examples
91+
92+
<!-- eslint no-undef: "error" -->
93+
94+
```javascript
95+
var linspace = require( '@stdlib/array/linspace' );
96+
var iterCartesianSquare = require( '@stdlib/iter/cartesian-square' );
97+
98+
var x = linspace( 0, 5, 6 );
99+
100+
// Create an iterator which iteratively computes the Cartesian square:
101+
var it = iterCartesianSquare( x );
102+
103+
// Perform manual iteration...
104+
var v;
105+
while ( true ) {
106+
v = it.next();
107+
if ( v.done ) {
108+
break;
109+
}
110+
console.log( v.value );
111+
}
112+
```
113+
114+
</section>
115+
116+
<!-- /.examples -->
117+
118+
<!-- 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. -->
119+
120+
<section class="references">
121+
122+
</section>
123+
124+
<!-- /.references -->
125+
126+
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
127+
128+
<section class="related">
129+
130+
* * *
131+
132+
## See Also
133+
134+
- <span class="package-name">[`@stdlib/array/cartesian-square`][@stdlib/array/cartesian-square]</span><span class="delimiter">: </span><span class="description">return then Cartesian square.</span>
135+
136+
</section>
137+
138+
<!-- /.related -->
139+
140+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
141+
142+
<section class="links">
143+
144+
[mdn-iterator-protocol]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterator_protocol
145+
146+
<!-- <related-links> -->
147+
148+
[@stdlib/array/cartesian-square]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/cartesian-square
149+
150+
<!-- </related-links> -->
151+
152+
</section>
153+
154+
<!-- /.links -->

0 commit comments

Comments
 (0)