The forms of this idiom that assign the result to a name
benefit from some special code:

  The phrase b}x,:y for numeric x and y is equivalent to the
  well-known phrase (x*b)+y*-.b . Recently, special code has
  been implemented for the phrase name=: c}x,y,...,:z , with
  boolean c as a special case, and the amendment is done in
  place if name is x or y and c is boolean. (In-place
  amendment is eschewed for integral c due to the possibility
  of index error.)

Henry Rich

> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of R.E. Boss
> Sent: Wednesday, October 25, 2006 6:45 AM
> To: 'Programming forum'
> Subject: RE: [Jprogramming] Choose Operators
> 
> This is what makes J so attractive, one is pleasantly surprised by an
> elegant solution. Perfect.
> 
> Remarkable that both questions had the same solution.
> 
> R.E. Boss
> 
> 
> 
> -----Oorspronkelijk bericht-----
> Van: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] Namens Devon McCormick
> Verzonden: woensdag 25 oktober 2006 2:51
> Aan: Programming forum
> Onderwerp: Re: [Jprogramming] Choose Operators
> 
> This is an idiom - I don't remember where I first saw it:
> 
>    B=. 1=2|X0=. 999+ X1=. i.10
> 
>    B,X0,:X1
>   1    0    1    0    1    0    1    0    1    0
> 999 1000 1001 1002 1003 1004 1005 1006 1007 1008
>   0    1    2    3    4    5    6    7    8    9
> 
>    B}X0,:X1
> 0 1000 2 1002 4 1004 6 1006 8 1008
> 
> 
> On 10/24/06, Leigh J. Halliwell <[EMAIL PROTECTED]> wrote:
> >
> > Thank you, Roger and Cliff.  On my first question I was 
> indeed thinking of
> > the monadic amend.  And Cliff's use of it for my second 
> question is nice,
> > too.  But I'd still like to know how to make the 
> identity/left operator
> > work
> > one-to one, as per my second question:
> >
> > "2) X0 and X1 are numeric vectors, and B is a Boolean 
> vector.  They all
> > have
> > the same length.  I'd like to select from X0 where B is 0, 
> and from X1
> > where
> > B is 1.  I try the expression: X1 [^:B X0.  But the adverb 
> ^:B wants to
> > get
> > two-dimensional, i.e., to apply each B to every pair of X1 
> and X2.  How
> > can
> > I make J to apply the adverb one-to-one with the arguments?"
> >
> > Sincerely,
> > Leigh
> >
> >
> > 
> ----------------------------------------------------------------------
> > For information about J forums see 
> http://www.jsoftware.com/forums.htm
> >
> >
> 
> 
> -- 
> Devon McCormick
> ^me^ at acm.
> org is my
> preferred e-mail
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
> 
> ----------------------------------------------------------------------
> For information about J forums see 
> http://www.jsoftware.com/forums.htm

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

Reply via email to