2016 Update
This commit is contained in:
parent
948b86eafa
commit
dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions
|
|
@ -0,0 +1,3 @@
|
|||
f = { |m| {:x, x<-(0..) } ** m };
|
||||
g = f.(2);
|
||||
g.nextN(10); // answers [ 0, 1, 4, 9, 16, 25, 36, 49, 64, 81 ]
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
(
|
||||
f = Pseries(0, 1)
|
||||
g = f ** 2;
|
||||
g.asStream.nextN(10); // answers [ 0, 1, 4, 9, 16, 25, 36, 49, 64, 81 ]
|
||||
)
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
(
|
||||
var filter = { |a, b, func| // both streams are assumed to be ordered
|
||||
Prout {
|
||||
var astr, bstr;
|
||||
var aval, bval;
|
||||
astr = a.asStream;
|
||||
bstr = b.asStream;
|
||||
bval = bstr.next;
|
||||
while {
|
||||
aval = astr.next;
|
||||
aval.notNil
|
||||
} {
|
||||
while {
|
||||
bval.notNil and: { bval < aval }
|
||||
} {
|
||||
bval = bstr.next;
|
||||
};
|
||||
if(func.value(aval, bval)) { aval.yield };
|
||||
}
|
||||
}
|
||||
};
|
||||
var without = filter.(_, _, { |a, b| a != b }); // partially apply function
|
||||
|
||||
f = Pseries(0, 1);
|
||||
|
||||
g = without.(f ** 2, f ** 3);
|
||||
h = g.drop(20);
|
||||
h.asStream.nextN(10);
|
||||
)
|
||||
|
||||
answers: [ 529, 576, 625, 676, 784, 841, 900, 961, 1024, 1089 ]
|
||||
Loading…
Add table
Add a link
Reference in a new issue