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
