On 10/4/07, Alistair Tucker <[EMAIL PROTECTED]> wrote:
> Seems clumsy and probably inefficient ... was wondering if anybody
> could think of a better way?

A better way for what?  Is your
  shave=:  #@:$ 0&(0&|:@:}:@:])
meant to be used as a monad?  a dyad?  Is it used for all ranks
of arrays?  Or only certain ranks (if a dyad, for either left or
right arguments)?

That said, note that the outer most 0& can be removed, as that
0 is being provided as a left argument to ] -- and with this removal
the parenthesis become redundant.

  alt1=: #@:$ 0&|:@:}:@:]

Also, since this is a hook, once this has been rephrased you
no no longer nened the @:] and because }: as a monad has
infinite rank you can further rephrase this as

   alt2=: #@:$ 0&|:@}:

Ultimately, your result is always going to be a relatively small
non-negative integer (produced by monadic #) so it seems likely
that an alternative expression could be formed for reasonably
constrained domains.  However, if you must support both monad
and dyad forms for arguments of arbitrary rank, I'd probably
stick with alt2.

.. but I'd be tremendously curious as to the purpose of this
expression if the monad and the dyad were both important
for arbitrarily ranked arrays.

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

Reply via email to