1
$\begingroup$

How do I pick a single element from a set that satisfies a property? For instance, I want to write something like this:

$S = S - \{s \in S \ | \ s \text{ is pretty}\}$

But with $\{s \in S \ | \ s \text{ is pretty}\}$ I want to pick a single element (any of the pretty ones).

Edit: If possible, the answer should be in a syntax similar to the definition of a set.

  • 0
    @TaraB: yes, a pseudo-algor$i$thm.2012-05-03

2 Answers 2

7

You say "Let $p$ be a pretty element of $S$, and let $S' = S - \{p\}$".

Of course you have to show first that $S$ does have at least one pretty element.

  • 0
    @Tara: Done!$\quad$2012-05-04
3

I'm still not entirely sure just what you want, but perhaps you could define an operator Arb on sets such that Arb(S) returns an arbitrary member of $S$ if $S\ne\varnothing$; then you can have assignments like $S'=S\setminus\Big\{\operatorname{Arb}\{s\in S:s\text{ is pretty}\}\Big\}\;.$

  • 0
    Just one thing. What is this "\"? Does it have the same effect as a "-"?2012-05-04