How would you create such an output in q:
,0
0 1
0 1 2
0 1 2 3
0 1 2 3 4
Probably your solution would be like this:
til each 1+til 5
But there is also other way which is even faster:
enlist[enlist 0],0,\1+til 4
Well, at least my PC states that it is faster ;)
q> \t do[1000;enlist[enlist 0],0,\1+til 400]
98
q> \t do[1000;til each 1+til 401]
171
Even Nicer Solution
Instead of complicated
enlist[enlist 0],0,\1+til 400
use short and sweet
(,\) til 401
Thanks, Rs!
Nice, but how about (,\) til 401?
Even better! Short and sweet.
there is also one
{x,y}scan til 100
Thanks Ajay for another solution! We are almost as good as ancient Egyptians ;-) However, isn’t this one slower?
On my machine, this is about 10-15ms faster:
\t do[1000;#\:[;til 401]1+til 401]