How do I call elements of ArrayRules
by their indices rather than by Part[ArrayRules[list],i]
? I'd like to call the element that looks like {i, j}-> val
by referring to the pair {i, j}
rather than by a single numerical index denoting the location within the list.
The reason for this is I would like to create a new SparseArray
based on the elements of a list, but I can't figure out how to change val
in ArraryRules
while preserving the rules that map it to a SparseArray
.
I'd like to call a specific element {i, j}
and assign the rules {i, j}-> newval
sparse[[i,j]]=newval
...? $\endgroup$Normal@KeyTake[atest, {{1, 1}, {2, 2}}]
? for{1,1}
and{2,2}
elements as axample? $\endgroup$arrayrules /. ({i, j} -> _) :> {i, j} -> newval
orarrayrules /. (idx -> _) :> idx -> newval
, whereidx
is the{i,j}
pair? $\endgroup$