I think you are wrong to characterize pipelines as vectorized.
Vectorized code (as I understand it) is like your first example -- R's * is defined for scalars, but automatically scales to vectors as well.
grep, on the other hand, is implemented for vectors (of strings). A program that checks whether a single line of stdin matches a regular expression would not work the same way.
So it is more accurate to say that grep is vectorized (as are many other programs), rather than pipelines allowing vectorizing.
Of course, pipelines allow vectorizing in another form -- through the use of xargs, which allows you to take a program that operates on one command-line argument and use it on an arbitrary amount of inputs.
I know I'm a bit late for this, but I've just discovered the blog and am reading through the backlog.
Hm if you want to say that grep and similar tools are vectorized, but pipelines aren't necessarily, sure I would agree that's technically more accurate.
You can definitely use pipelines on single "things" like ELF files, although that doesn't happen to be too common. Or images like .jpg.
1
u/Ergoold Jan 07 '22
I think you are wrong to characterize pipelines as vectorized.
Vectorized code (as I understand it) is like your first example -- R's
*is defined for scalars, but automatically scales to vectors as well.grep, on the other hand, is implemented for vectors (of strings). A program that checks whether a single line of stdin matches a regular expression would not work the same way.So it is more accurate to say that
grepis vectorized (as are many other programs), rather than pipelines allowing vectorizing.Of course, pipelines allow vectorizing in another form -- through the use of
xargs, which allows you to take a program that operates on one command-line argument and use it on an arbitrary amount of inputs.I know I'm a bit late for this, but I've just discovered the blog and am reading through the backlog.