APL knows which operators commutate and which may be merged. I've often thought about the same for the pipeline, but never come up with anything.

Still a way to capping the insertion sort at n records would be trivial (he says without looking). Is there a requirement?


On 09/06/2013 04:13 PM, Glenn Knickerbocker wrote:
On 9/5/2013 5:12 PM, Michael Harding wrote:
|Spec printonly EOF a: w3 . set (#0+=1;#5:=a)',
   'if #5>#1 then',
Wrong way around.  You can *use* the fields in the IF clause,
just not *define* them there:

   '|Spec printonly EOF a: w3 .',
     'b: substr 1.8 of w2 . c: substr 9.6 of w2 .',
     'if a>#1 then',
        'set (#1:=a;#2:=b;#3:=c) fi',
   etc.

What you're doing here is a limited implementation of something I've
wished for forever:  a sort that keeps only a specified number of the
highest or lowest values, so the whole file doesn't have to fit in
storage.  It would replace:

   ... | sort w3 d | take 1 | ...

with a single stage:

   ... | sort w3 d take 1 | ...

¬R

Reply via email to