If such record exists, I need to return its d field. I currently use CHOOSE to select such a record:
R(r) == CHOOSE x \in r : TRUE
Read(r) ==
/\ r.op = "R"
/\ LET d == {x \in data : x.id = r.id}
IN IF d = {} THEN
qout' = Append(qout, [code|->"ERR"])
ELSE
qout' = Append(qout, [code|->"OK", d|->R(d).d])
/\ UNCHANGED <<data>>
Is there a better way to achieve this?
Thank you,
Yuri