Array selection & selective assignment

General discussions on potential enhancements to the APL+Win system.

Array selection & selective assignment

Postby Ajay Askoolum » January 15th, 2012, 8:50 am

given an array of rank 2 or above, I'd like to be able to do

1. return the elements where the condition is true as a vector e.g.

array[array >10]

2. selectively reassign those elements

array[array >10] <- 0

I know that both are achievable with a slight rearrangement of the syntax but what I propose is an intuitive extension.
Ajay Askoolum
 
Posts: 884
Joined: February 22nd, 2007, 2:16 am
Location: United Kingdom

Postby aplus » January 16th, 2012, 8:47 pm

How about simply doing this:

Code: Select all
     Å’„A„5 5½¼25
  1  2  3  4  5
  6  7  8  9 10
 11 12 13 14 15
 16 17 18 19 20
 21 22 23 24 25
      ((,A)[((,A)>15)/¼½,A])„0
      A
  1  2  3  4  5
  6  7  8  9 10
 11 12 13 14 15
  0  0  0  0  0
  0  0  0  0  0
aplus
 
Posts: 164
Joined: April 16th, 2007, 2:21 pm
Location: Allentown, PA

Postby Ajay Askoolum » January 17th, 2012, 5:09 am

I think I did mention that I know the alternative syntax & proposed the implementation as it is simpler (to me, more intuitive).
But, thanks for the suggestion.
Ajay Askoolum
 
Posts: 884
Joined: February 22nd, 2007, 2:16 am
Location: United Kingdom


Return to APL+Win Wish-List

Who is online

Users browsing this forum: No registered users and 18 guests

cron