Say you are given a list of numbers & you want to throw away the first & last and box the rest.  You produce

<@}.@}:

How'd you do?

The }: and }. will produce virtual blocks, and the < will realize the result, so the data is moved only once.  Top marks?

No.  If you use this verb in a partition, say

<@}.@}: ;. 1

you have left some performance on the table.  The result-assembly code detects verbs of the form

<@f  or <@:f  or ([: < f)

where every result-cell is known in advance to be boxed.  For general verbs it has to worry about the possibility of dissimilar types and shapes, but for verbs of this form it knows each result-cell  is a scalar box and it can plan accordingly.

But you didn't provide such a verb!  You offered

<@}.@}:  which is the same as (<@}.)@}:  .  It's not what result-assembly is looking for.

For full marks you should have coded

<@(}.@}:)

Henry Rich

---
This email has been checked for viruses by AVG.
http://www.avg.com

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to