I have a fairly complicated Association. I wish to use/create a function such as ReplacePart to operate on certain Keys within this multi-level Association.
Here's a toy example:
assoc = <|
"PARAMETERS" -> <|"A" -> 1, "B" -> 2|>,
"PHASES" -> <|
"LIQUID" :> (assoc["PARAMETERS", "B"]*# &),
"GAS" :> (assoc["PHASES", "LIQUID"][#] *0.5* # &)
|>
|>
This Association contains two functions which are used to calculate endless other trivial stuff.
We can use them like so:
Plot[assoc["PHASES", "GAS"][x], {x, -5, 5}]

Now, it's not hard to change one of these functions:
assoc["PHASES", "GAS"] := assoc["PHASES", "LIQUID"][#] * 0.7 * # &
...and this works perfectly fine. But in practice, I might be changing these functions or other values many times and a programmatic way would be preferred.
I'm picturing something like this:
newassoc = ReplacePart[assoc, {{"PHASES", "GAS"} :> assoc["PHASES", "LIQUID"][#] * 0.7 * # &, {"PARAMETERS", "A"} -> 15}]
<| "PARAMETERS" -> <|"A" -> 15, "B" -> 2|>, "PHASES" -> <| "LIQUID" :> (assoc["PARAMETERS", "B"]*# &), "GAS" :> (assoc["PHASES", "LIQUID"][#] *0.7* # &) |> |>
However, it doesn't appear ReplacePart works on Associations, and with my ineptitude at non-standard evaluation, I'm having trouble coming up with a way to do this.
I genuinely hope I've just looked over an easy solution, but any help is greatly appreciated.
