It is not clear to me why this function does not work:
setHome[c_, i_] := (c[["h"]] = i);
testCd = <|"s" -> "a", "v" -> 1, "h" -> 0, "n" -> 0, "x" -> 0|>
setHome[testCd, 5]
testCd
But this works perfectly:
the2s = {<|"s" -> "a", "v" -> 2, "h" -> 0, "n" -> {"a", 3}, "x" -> 0|>,
<|"s" -> "b", "v" -> 2, "h" -> 0, "n" -> {"b", 3}, "x" -> 0|>,
<|"s" -> "c", "v" -> 2, "h" -> 0, "n" -> {"c", 3}, "x" -> 0|>,
<|"s" -> "d", "v" -> 2, "h" -> 0, "n" -> {"d", 3}, "x" -> 0|>}
start2s = {28, 41, 2, 15};
(the2s[[#, "h"]] = start2s[[#]]) & /@ Range[Length[the2s]]
MatrixForm[the2s]
Can someone make clear to me what I am missing?