Bill is right when he points out how you impose extra work on people by not
providing an executable definition of your array like this:

    ]Cm1kb=. ([:|:,:)&.>1 3 4;0 2 4;0 1 2 4;2 4;0 1 2 3
+-+-+-+-+-+
|1|0|0|2|0|
|3|2|1|4|1|
|4|4|2| |2|
| | |4| |3|
+-+-+-+-+-+

You also don't give the answer you say is correct:
   (1 1$0) e. 2 pick Cm1kb
1

So,
   (<1 1$0) e. each Cm1kb
+-+-+-+-+-+
|0|1|1|0|1|
+-+-+-+-+-+

From your use of one-column tables and "1 1$", my guess is that you're
coming from a Matlab background and are trying to force all arrays into the
2-D pattern it favors.

A more J way would be to treat simple vectors this way:
   0 e. &.> 1 3 4;0 2 4;0 1 2 4;2 4;0 1 2 3
+-+-+-+-+-+
|0|1|1|0|1|
+-+-+-+-+-+

On Fri, Nov 13, 2009 at 9:23 PM, bill lam <[email protected]> wrote:

> On Wed, 11 Nov 2009, R.  Kars  Brouwer wrote:
> >
> >
> >
> >
> > Ckm1b is the 5 boxes
> >
> > --T-T-T-T-┐
> >
> > │1│0│0│2│0│
> >
> > │3│2│1│4│1│
> >
> > │4│4│2│ │2│
> >
> > │ │ │4│ │3│
> >
> > L-+-+-+-+--
> >
> > The components are  3 by 1,  3 by 1,  4 by 1 , 2 by 1 and 4 by 1 arrays
> >
> >
> > $ each Ckm1b  works and gives
> >
> > ----T---T---T---T---┐
> >
> > │3 1│3 1│4 1│2 1│4 1│
> >
> > L---+---+---+---+----
> >
> > (1  1 $ 0) e. 2 pick Cm1kb gives me the right answer and so do the other
> > picks  but  (1  1 $ 0) e. each Cm1kb gives me a length error. Why is
> that?
> > What can I do?
>
> try
> (1  1 $ 0)&e.&.> Cm1kb
>
> untested because you did not provide the definition of Cm1kb that can
> be easily tested by copy and paste.
>
> BTW >@{ or {:: is more clear then 'pick'
>
> --
> regards,
> ====================================================
> GPG key 1024D/4434BAB3 2008-08-24
> gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>



-- 
Devon McCormick, CFA
^me^ at acm.
org is my
preferred e-mail
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to