Jsoftware
High-Performance Development Platform

problem with each

View: New views
4 Messages — Rating Filter:   Alert me  

problem with each

by Roelof K Brouwer :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

 

 

 

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?

 

 

Cheers

 

Kars

 

 

R.  Kars Brouwer Ph.D.  P.Eng.

Professor Emeritus

Dept. of Computing Science

School of Advanced Technologies and Mathematics

Thompson Rivers University

900 McGill Road

Kamloops, BC

Canada, V2C 5N3

 

email : rkbrouwer@...

 

http://www.tru.ca/faculty/rbrouwer/

 

 

 

 

 

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

Re: problem with each

by Devon McCormick :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

You probably need to enclose your left argument to make it compatible, e.g.
   (<1 1$0) e. each Cm1kb
but I haven't verified this.

2009/11/11 R. Kars Brouwer <rkbrouwer@...>

> ...
> (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?
>
>
--
Devon McCormick, CFA
^me^ at acm.
org is my
preferred e-mail
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Re: problem with each

by bill lam-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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

Re: problem with each

by Devon McCormick :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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 <bbill.lam@...> 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