bug-apl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-apl] Select from a two-dimensional array


From: David B. Lamkins
Subject: Re: [Bug-apl] Select from a two-dimensional array
Date: Sat, 02 Aug 2014 21:37:05 -0700

Assuming you want a ravel of the elements under the mask:

      a←2 3⍴1 2 3 4 1 2
      b←2 3⍴0 0 1 0 0 0
      a
1 2 3
4 1 2
      b
0 0 1
0 0 0
      (,b)/,a
3


On Sun, 2014-08-03 at 00:12 +0800, Elias Mårtenson wrote:
> Here's a problem I've had on multiple occasions, and I have yet to
> figure out a nice generic way of dealing with it.
> 
> 
> For a one-dimensional array, I can easily select elements based on a
> bitmap:
> 
> 
>       0 0 1 0 0 0/⍳6
> 3
> 
> 
> Sometimes I want to do the same from a two (or more) dimensional
> array:
> 
> 
>       a
> 1 2 3
> 4 1 2
>       b
> 0 0 1
> 0 0 0
>       b/a
> RANK ERROR
>       b/a
>       ^ ^
> 
> 
> How to do this?
> 
> 
> Regards,
> Elias





reply via email to

[Prev in Thread] Current Thread [Next in Thread]