-
-
Notifications
You must be signed in to change notification settings - Fork 602
Commit
math/iter/sequences
PR-URL: #1779 Ref: #1577 Co-authored-by: Philipp Burckhardt <pburckhardt@outlook.com> Reviewed-by: Philipp Burckhardt <pburckhardt@outlook.com>
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,42 @@ | |
|
||
'use strict'; | ||
|
||
var objectKeys = require( '@stdlib/utils/keys' ); | ||
var ns = require( './../lib' ); | ||
var ns = require('./../lib'); | ||
Check failure on line 21 in lib/node_modules/@stdlib/math/iter/sequences/examples/index.js GitHub Actions / Lint Changed Files
|
||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
||
|
||
console.log( objectKeys( ns ) ); | ||
// Create iterators for generating square and cube numbers: | ||
var squares = ns.iterSquaresSeq(); | ||
var cubes = ns.iterCubesSeq(); | ||
|
||
// Iterate over both sequences and log the first five pairs: | ||
var square; | ||
This comment has been minimized.
Sorry, something went wrong.
kgryte
Member
|
||
var cube; | ||
var i; | ||
for ( i = 0; i < 5; i++ ) { | ||
square = squares.next().value; | ||
cube = cubes.next().value; | ||
console.log( 'Square: %d, Cube: %d', square, cube ); | ||
} | ||
|
||
// Calculate the sum of the first 10 Fibonacci numbers: | ||
var fibonacci = ns.iterFibonacciSeq({ | ||
'iter': 10 | ||
}); | ||
var sum = 0; | ||
var v = fibonacci.next(); | ||
while ( v.done === false ) { | ||
sum += v.value; | ||
v = fibonacci.next(); | ||
} | ||
console.log( 'Sum of first 10 Fibonacci numbers: %d', sum ); | ||
|
||
// Generate prime numbers: | ||
var primes = ns.iterPrimesSeq({ | ||
'iter': 10 | ||
}); | ||
|
||
console.log( 'First ten prime numbers:' ); | ||
v = primes.next(); | ||
while ( v.done === false ) { | ||
console.log( v.value ); | ||
v = primes.next(); | ||
} |
1 comment
on commit e469715
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Coverage Report
Package | Statements | Branches | Functions | Lines |
---|---|---|---|---|
math/iter/sequences |
|
|
|
|
The above coverage report was generated for the changes in this push.
@Planeshifter Missing spaces in the require statement.