When the indices to @. are in order and unboxed, the "agenda trick" is
overkill. Straightforward, non-tricky adverbs can be defined tacitly with
(`:6), as in
first =: (`i.) (`1:) (`:6)
retitem =: ({~`) (]`) (`:6)
If you care for a longer exposition, see [1].
-Dan
[1] "A phrase for amendment" & a primer on how to write adverbs tacitly:
http://www.jsoftware.com/pipermail/programming/2010-November/021172.html
Please excuse typos; composed on a handheld device.
> On Nov 2, 2013, at 4:54 PM, Pascal Jasmin <[email protected]> wrote:
>
>
>
> I assume only the agenda trick can do it tacitly:
>
> firstT =: (`(i.`1:))(@.(<0 1 2))
>
> There is an upto 10% performance improvement (sometimes in J6. Not J7) in
> the tacit version but both are very fast.
>
> ----- Original Message -----
> From: Pascal Jasmin <[email protected]>
> To: "[email protected]" <[email protected]>
> Cc:
> Sent: Saturday, November 2, 2013 2:06:56 PM
> Subject: [Jprogramming] making a 'first' adverb tacit
>
> I'm pleased that this is as elegant as it is already, but can the 2 adverbs
> be defined tacitly?
>
> first =: 1 : 'u i. 1:'
> retitem =: 1 : '] {~ u'
>
> (4<])first i.7
> 5
> 4< first i.7
> 5
>
> Its nice that the adverb doesn't require a duplicate dyadic definition.
>
> 4< first >:i.7
> 4
> 4< first retitem >:i.7
> 5
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm