Thread resurrection, only because this happens to look rather cool syntax-wise with my recent experiment/invention Pforai; it basically says "take the zero (as a stream of zeros) and pair each value/zero with every item from the [2, 4, 6] array. The combine/merging function [_,_]
in this case is just “merging” by pariing into a 2-element array:
Pbind(\degree, Pforai(0, [2, 4, 6], [_,_])).trace.play;
The array for Pforai can be a pattern or stream too, i.e the row can change after a full previous row is “done”. For immediate swap I have a Pforp variant
Pbind(\degree, Pforp(0, Pseq([2, 4, 6]), [_,_])).trace.play;
Merely for combining arrays by interleaving there’s actually Place
in the standard library, but here you also have to [P]clump the result:
Pbind(\degree, Place([0, [2, 4, 6]], inf).clump(2)).trace.play
Place
doesn’t take patterns for the array, but there’s Ppatlace
which does.
Also worth a mention
Pbind(\degree, Pbinop(\pair, 0, Pseq([2, 4, 6], inf))).trace.play; //or
Pbind(\degree, Pbinop(\pair, 0, Pseq([2, 4, 6]), 'x')).trace.play;
since there are many more methods defined than Psomethings, if you can find a method already defined that does what you want but isn’t “patternized” you can just the above technique. (Although in this case you do have Ptuple.) There’s an Event-based hack that allows one to use Pbinop with arbitrary functions as pseudo-operators, but it’s seldom worth it, when you can use Pcollect etc. which take functions as input.