Thank you for the explanation and materials.
I have defined the following:
firstTrue =: $ $ ((((+. {.) 0 } ]) , (> {.)) / @ (0 ,~ |.@,) (}. @))
(,: firstTrue) (2 3 $ 0 0 1 0 1 0 1 0 0)
0 0 1
0 1 0
0 0 1
0 0 0
What I have is a tally (is that what it's called?) of an array which
I'm working on, and I would like to extract this first true element
and also I will use the result of firstTrue on the previous tally by
combining it with some logical operations.
On 1 October 2010 18:47, Dan Bron <[email protected]> wrote:
> Justin Paston-Cooper wrote:
>> Is there an abbreviation or better way of
>> doing <<($ $ v@,)>>
>
> If you just want an adverb for it, then
>
> UnderRavel =: (@,) ($`) ($`) (`:6)
>
> v UnderRavel
> $ $ v@,
>
> or UnderRavel =: adverb def '$ $ u@,' might be more readable if you're
> not comfortable with tacit adverbs.
>
> Sad, in the good old days [J4] we could have written UnderRavel =: @, $~ $ .
> This was my first tacit adverb (early 2000s), and I remember being very
> proud when I "invented" it. Until a moment later, when I remembered Kirk
> Iverson had showed it to me before (or at least the key idea of commuting
> the middle tine and putting the @ on the left, so it could accept an
> argument instead of being immediately bound to the $). None the less, I
> kept it around in my utilities script for a while.
>
>> where v is a monad
>
> in �...@u v will be invoked as a monad, whether it likes it or not (so v is a
> monad by definition). But yes, we are discussing the whole verb $ $ v@,
> only as a monad.
>
> Roger wrote:
>> I'd like to see what such a v is.
>
> I'd like to know the use case too; this idiom sees interesting applications
> (e.g. [1-5]). It also has a brother in UnderNub =: ( @:(#~ ] = i.@:#) )
> ({`) (]`) (`:6) (` (i.~) ) (`:6) or 1 : '(] { u@:(#~ ] = i.@:#)) i.~'
> which helps with expensive (but functional) u .
>
> -Dan
>
> [1] a - mark across words > 1 letter in a crossword puzzle
>
> a =: $ $ (0: , }: (#^:_1) 2: < |@(2: -/;._3 (# i...@#)))@,
>
> http://www.jsoftware.com/pipermail/general/2004-March/016671.html
>
> [2] glqextentwm - query the size (extent) of a text matrix you want to
> display
> (i.e. turn a matrix into a vector for a 3rd party library to consume,
> then convert it back):
>
> qextentwm=: $ $ qextentwv@,
>
>
> http://www.jsoftware.com/trac/base/browser/branches/cdb/grid/base/util/util.
> ijs#L72
> http://www.jsoftware.com/pipermail/beta/2005-December/000215.html
>
>
> [3] zz2 - zig-zag matrix:
>
> zz2 =: ($ $ [: /:@:; <@:|.`</.)@:i.@:,~
>
>
> http://www.jsoftware.com/pipermail/programming/2006-November/004156.html
>
> [4] across - apply gerund left to array on right.
>
> across=: adverb def '1 ( ({.(}...@$ $ ,)`[) A u );.1 ]'
>
>
> http://www.jsoftware.com/pipermail/programming/2006-December/004287.html
>
> [5] The Forum search utility really has some nice features;
> here, searching for the "exact phrase" $ $ along with
> @, made this research easy:
>
>
> http://www.jsoftware.com/cgi-bin/forumsearch.cgi?all=%40%2C&exa=%24+%24&one=
> &exc=&add=&sub=&fid=&tim=0&rng=0&dbgn=1&mbgn=1&ybgn=1998&dend=31&mend=12¥
> d=2010
>
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm