So, I have never used sparse arrays in J before, and am puzzled by some of the 
behavior.
If I initialize an integer sparse vector BID, and set element 10 to be 90:

BID=: 1 $. 100;0;3-3
BID=: (90) 10}BID
  BID
10 │ 90


Cool;  but then, if I want to zero out the 10 element

BID=: (90-90) 10}BID
   BID
10 │ 0
   

Not cool; especially when I want to use 4&$. to find the nonzero elements:
   4&$.BID
10


Am I expecting too much from sparse vectors? Or am I assuming something silly? 
FWIIW, I checked on 702 and 801; same behavior. Was trying to use sparse 
vectors as a sort of numeric keyed hash table. It's probably not much use doing 
this if the 0 valued elements return an index with 4&$.
Thanks for any insights,

-Scott
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to