On Fri, Aug 29, 2008 at 2:13 AM, Saunders, John (HEALTH)
<[EMAIL PROTECTED]> wrote:
> annmatch=: 3 : 0
> countmatches=: a:
> for_a.
> y
> do. countmatches=: countmatches,(<( {: /:>(+/ each a e. each bals)))
> end.
> }.countmatches
> )
I am not sure what your data looks like, but I suspect that your
sentence
countmatches=: countmatches,(<( {: /:>(+/ each a e. each bals)))
could be rephrased as
countmatches=: countmatches,(<( {: /:a +/@e.&>bals))
That said, personally I prefer to eliminate unnecessary parenthesis,
since they get in the way of me understanding the sentences, so I
would use
countmatches=: countmatches,< {: /:a +/@e.&>bals
Also, I am curious about your data -- does your 'countmatches'
list really need to be a list of boxes? Or would (with Alex's
suggestion and a corresponding change in whatever you have
that consumes the result of this verb, could you be using
countmatches=: countmatches,{: /:a +/@e.&>bals
Or, even
countmatches=: countmatches,(i.>./)a +/@e.&>bals
which takes advantage of the special code mentioned
at http://www.jsoftware.com/help/release/idot504.htm
And, finally, if I have guessed right, and if bal is not
too long, I suspect that you could make your routine
dyadic by using:
annmatch=: (i.>./)@((+/)@e.&>"0 1)
This works by combining the above suggestions and
replacing your looping construct with an expression
of the form:
part2 @ (part 1 " 0 1)
The clause "0 1 means that the part1 verb will be
used against individual atoms from the left argument
and against the list of atoms from the right argument.
And that '@' means that the part2 verb will be applied
independently to each of the results created by the
part1 verb.
FYI,
--
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm