[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Need help to update the state with EXCEPT.



rslInitState == [machine \in 1..MachinesInRing |->
						 [scaleUnit |-> machine,
						  isNodeUp |-> TRUE,
						  isPrimary |-> FALSE]]

hkInitState == [machine \in 1..MachinesInRing |->
						   [state |-> "init",
							retryCount |-> 1]]

inMemoryState = [p \in RMs |->
							[rslState |-> rslInitState,
							hkState |-> hkInitState ,
							isDriver |-> FALSE]]

I have one "inMemoryState", show above is the init state.

Now in one of the function I want to change the inMemoryState of All RMs and all machines, hkState.state to "working" while rest I want to keep it same.
Example, inMemoryState[r].hkState[1..MachinesInRing].state = "working"

I can do something like below.
/\ inMemoryState' = [lp \in RMs |->
                             [m \in 1..MachinesInRing |->
                                IF p = lp
                                    THEN []
                                ELSE []]]

But is there an easy way where I can use EXCEPT and do the same in one line ?