Re: boolean indexing for subset reassignment
- To: mathgroup at smc.vnet.net
 - Subject: [mg132635] Re: boolean indexing for subset reassignment
 - From: Bill Rowe <readnews at sbcglobal.net>
 - Date: Sat, 26 Apr 2014 02:07:30 -0400 (EDT)
 - Delivered-to: l-mathgroup@mail-archive0.wolfram.com
 - Delivered-to: l-mathgroup@wolfram.com
 - Delivered-to: mathgroup-outx@smc.vnet.net
 - Delivered-to: mathgroup-newsendx@smc.vnet.net
 
On 4/25/14 at 12:44 AM, alan.isaac at gmail.com (Alan) wrote:
>Thanks for taking a stab at this, but you have not described
>comparable functionality.  Most importantly, you are not changing
>the list `b` in place.
I don't understand why you do not see what I had posted as
comparable since it outputs the same result as described. If
your objection is simply I did not modify the original array,
that is trivial to change.  Where I had posted
m = b Unitize@Clip[a, {1, 15}, {0, 0}]
this could be done as:
b = b Unitize@Clip[a, {1, 15}, {0, 0}]
which would change the original array.
In either case, what is returned is an array containing the
elements of b except those that exceed 15 which are replaced
with 0. That is:
In[18]:= a = RandomInteger[{1, 20}, {4, 3}]
Out[18]= {{8, 9, 11}, {16, 7, 20}, {4, 6, 3}, {12, 13, 16}}
In[19]:= b = RandomReal[1, {4, 3}];
b = b Unitize@Clip[a, {1, 15}, {0, 0}];
In[21]:= a Unitize[b]
Out[21]= {{8, 9, 11}, {0, 7, 0}, {4, 6, 3}, {12, 13, 0}}
showing b now has a 0 where a has a value greater than 15