User defined pipe and redirection operators: Difference between revisions

J pre-draft
(+perl)
(J pre-draft)
Line 34:
Pioneer: Adriaan van Wijngaarden - Dutch pioneer; ARRA, ALGOL
</pre>
 
=={{header|J}}==
 
If we ignore the gratuitous complexity requirements of this task, it boils down to this:
 
Step 0: get the data. The task does not specify how to get the data, so here I use lynx, which is readily available on most unix-like systems, including cygwin. Note that lynx needs to be in the OS PATH when running j.
 
<lang j>data=:<;._2 shell 'lynx -dump -nolist -width=999 http://en.wikipedia.org/wiki/List_of_computer_scientists'</lang>
 
Step 1: define task core algorithms:
 
<lang j>grep=: +./@E.S:0 # ]</lang>
 
Step 2: select and display the required data:
 
<lang j> ;'aa' grep 'ALGOL' grep data
* Adriaan van Wijngaarden - Dutch pioneer; ARRA, ALGOL
</lang>
 
As for the concept of a pipe that presents data one record at a time to a downstream function, that corresponds to the J operator <code>@</code> but it's not clear how to demonstrate that usefully, in this task. (And, I could write pages of code, to accomplish what's being accomplished here with the two successive greps, but I find that concept distasteful and tedious.)
 
=={{header|Perl}}==
6,951

edits