Hello,
your approach is correct. Instead of checking emptiness via cardinality, I’d rather use a direct set comparison. Also, you can avoid some repetition using a LET definition, like so:
get_element(key) ==
LET matches == { x \in some_set : x.key = key }
IN IF matches = {} THEN [ key |-> 0 ]
ELSE CHOOSE m \in matches : TRUE
Regards,
Stephan
> --
> You received this message because you are subscribed to the Google Groups "tlaplus" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
tlaplus+u...@googlegroups.com.
> To post to this group, send email to
tla...@googlegroups.com.
> Visit this group at
https://groups.google.com/group/tlaplus.
> For more options, visit
https://groups.google.com/d/optout.