Unfortunately, the built-in (bit) _set_ type doesn't have a _pop_ procedure (as does HashSet).
There must be something prettier than proc pop[T]( S:var set[T] ) : T = if card(S) == 0 : raise newException(IndexDefect,"pop on an empty set") var found : T for e in S : found= e break S.excl(found) found Run Many thanks for a hint, Helmut