This is the most elegant I can come up with
$O{"1&.|:"2 F
11 3 5
X-:O{"1&.|:"2 F
1
It was hidden in what Brouwer wrote before:
> I tried the following and it works
> 1|:(|:O)(({" 1 )" 2) 1|:F
R.E. Boss
-----Oorspronkelijk bericht-----
Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Namens Roger Hui
Verzonden: vrijdag 10 november 2006 19:06
Aan: General forum
Onderwerp: Re: [Jgeneral] selection expression in J
Alternative solutions:
X=: (<_2 _1) |: O {"2 F
X -: O 4 : 'x}y'"1 2"2 F
1
X -: (O ,&.>"1 i.{:$O) {"2 F
1
----- Original Message -----
From: Roger Hui <[EMAIL PROTECTED]>
Date: Friday, November 10, 2006 3:14 am
Subject: Re: [Jgeneral] selection expression in J
> O=: 3 5 [EMAIL PROTECTED] 7
> F=: 11 7 5 [EMAIL PROTECTED] 1000
> $ O {"2 F
> 11 3 5 5
> $ (<_2 _1) |: O {"2 F
> 11 3 5
>
>
>
> ----- Original Message -----
> From: "Brouwer, Roelof <[EMAIL PROTECTED]>" <[EMAIL PROTECTED]>
> Date: Friday, November 10, 2006 2:26 am
> Subject: RE: [Jgeneral] selection expression in J
>
> > The following would work if the first axis of X and F was not
> > there. But
> > even in the 2 axis case there might be a more elegant expression
> > withouthaving to do so many tranposes
> > X=.|:(|:O){"1 |:F
>
>
>
>
> > -----Original Message-----
> > From: [EMAIL PROTECTED]
> > [EMAIL PROTECTED] On Behalf Of Henry Rich
> > Sent: November 10, 2006 12:12 PM
> > To: 'General forum'
> > Subject: RE: [Jgeneral] selection expression in J
> >
> > x =: ((<s,((<p,a){O),a) { F) (<s,p,a)} x
> >
> > is a direct translation of what you wrote. Is that
> > what you want?
>
>
>
> > > -----Original Message-----
> > > From: [EMAIL PROTECTED]
> > > [EMAIL PROTECTED] On Behalf Of Brouwer,
> > > Roelof <[EMAIL PROTECTED]>
> > > Sent: Friday, November 10, 2006 4:27 AM
> > > To: General forum
> > > Subject: [Jgeneral] selection expression in J
> > >
> > > If I want
> > >
> > >
> > >
> > > X(s,p,a)<- F(s,O(p,a),a) s=0..ns-1 p=0..np-1 a=0..na-1
> > > O is np
> > > by na and O 's components have values 0..nv-1 ; F is ns
> > > by nv by na
> > > ; and X is ns by np by na
> > >
> > >
> > >
> > > What is an elegant J expression that will do the trick
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm