September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
|
|
@ -1,36 +0,0 @@
|
|||
function PowersGenerator(m) {
|
||||
var n=0;
|
||||
while(1) {
|
||||
yield Math.pow(n, m);
|
||||
n += 1;
|
||||
}
|
||||
}
|
||||
|
||||
function FilteredGenerator(g, f){
|
||||
var value = g.next();
|
||||
var filter = f.next();
|
||||
|
||||
while(1) {
|
||||
if( value < filter ) {
|
||||
yield value;
|
||||
value = g.next();
|
||||
} else if ( value > filter ) {
|
||||
filter = f.next();
|
||||
} else {
|
||||
value = g.next();
|
||||
filter = f.next();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
var squares = PowersGenerator(2);
|
||||
var cubes = PowersGenerator(3);
|
||||
|
||||
var filtered = FilteredGenerator(squares, cubes);
|
||||
|
||||
|
||||
|
||||
for( var x = 0; x < 20; x++ ) filtered.next()
|
||||
for( var x = 20; x < 30; x++ ) console.logfiltered.next());
|
||||
Loading…
Add table
Add a link
Reference in a new issue