A more obvious way is to use (c { b,.a) . The key is to realize that saying
(if c then a else b) is just selection: if c is 0, we pick b, and if c is
1, we pick a. So we rephrase as (c { b,a), and J's implicit rank allows us
to do (c { b,.a) for vector c, a, and b.

That said, (c} b,:a) is faster, and uses less memory by not actually
computing b,:a . So it's a better choice.

Marshall

On Wed, Dec 21, 2011 at 10:26 AM, Brian Schott <schott.br...@gmail.com>wrote:

> One way is the following.
>
>   c}b,:a
> 10 2 30
>
>
> --
> (B=)
> ----------------------------------------------------------------------
> 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