Search code examples
tla+pluscal

How to get a specific element from the set - PlusCal


Given the set, for example, {1, 2, 4, 10, 6} how can I get the element 4 to a variable var. What I want is to get element "4" from the set to a variable var: var = 4 And remove the element 4 from the set: set = {1, 2, 10, 6}


Solution

  • Based on the comments, it sounds like you want this:

    with x \in set do
       var := x;
       set := set \ {x};
    end with;