It sounds like you are asking for this:
fie=: ,:^:(2>#@$)
but you might want to consider alternatives such as:
foe=: , $~ _2{.1,$
or
fum=: ,.&.|:
Good luck,
--
Raul
On Fri, Oct 2, 2015 at 8:27 PM, Nollaig MacKenzie
<[email protected]> wrote:
>
>
> I have a variable, fee, which might have shape
> N,2 or just 2. I want a function that converts
> fee when it has shape 2 to shape 1 2.
>
> It seems straightforward: if the rank is 2,
> make no change, if 1, apply ,:
>
> So something like ,:`]@.(<:@$^:2) should
> do the trick. Indeed, this works:
>
> $ ,:`]@.(<:@$^:2 fee) fee=:'ab'
> 1 3
>
> But when I try to define something to do
> what I want, I get lost.
>
> ,:`]@.(<:@$^:2) fee=:'ab'
> |rank error
> | ,:`]@.(<:@$^:2)fee=:'ab'
> ,:`]@.(<:@$^:2 ]) fee=:'ab'
> |domain error
> | ,:`]@.(<:@$^:2]) fee=:'ab'
> ,:`]@.((<:@$^:2)@: ]) fee=:'ab'
> |rank error
> | ,:`]@.((<:@$^:2)@:]) fee=:'ab'
>
>
>
> (I'll spare you more)
>
> I must be missing something obvious.
>
> --
> Nollaig MacKenzie
> http://www.yorku.ca/nollaig
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm