I know that there’s a special BinaryOpXStream
used by Pbinop
when it encounters the .x
adverb, but I’ve been wondering why Pbinop
fails to produce anything with the regular BinaryOpStream
on the (related) .t
adverb in the following example:
[0, 0.1] +.t [0, 10, 100] // -> [ [ 0, 10, 100 ], [ 0.1, 10.1, 100.1 ] ]
(Pseries([0, 0.1], 1) +.t [0, 10, 100]).asStream.nextN(2) // -> [ nil, nil ]
// Workaround (internally uses Pcollect instead of Pbinop):
Pseries([0, 0.1]).collect({|a| a +.t [0, 10, 100]}).asStream.nextN(2)
// -> [ [ [ 0, 10, 100 ], [ 0.1, 10.1, 100.1 ] ], [ [ 1, 11, 101 ], [ 1.1, 11.1, 101.1 ] ] ]
Any ideas why does the middle example fails to produce/yield any non-nil output?
Actually, the problem seems to be a bit more general:
[0, 0.1] +.s [0, 10, 100] // -> [ 0, 10.1 ]
(Pseries([0, 0.1], 1) +.s [0, 10, 100]).asStream.nextN(2) // -> [ nil, nil ]
And it’s not that Pbinop doesn’t “see” the adverb, because passing it explicitly also fails the same way…
Pbinop('+', Pseries([0, 0.1], 1), [0, 10, 100], 's').asStream.nextN(2) // -> [ nil, nil ]
Non-adverbed stuff (fairly obviously) works though:
(Pseries([0, 0.1], 1) + [0, 10, 100]).asStream.nextN(2) // or
Pbinop('+', Pseries([0, 0.1], 1), [0, 10, 100]).asStream.nextN(2)
// -> [ [ 0, 10.1, 100 ], [ 1, 11.1, 101 ] ]