1
$\begingroup$

Is there a function/notation for converting a finite set $S$ into a tuple $T$ which contains the same elements? Likewise, is there a function/notation for converting a tuple into a set?

E.g. if $T = (1, 2, 5)$ then $S$ would be $\{1, 2, 5\}$.

I'm guessing that you can't convert a set to a tuple because sets are unordered, but a tuple to a set seems mathematically fine to me.

$\endgroup$
  • $\begingroup$ You are right. There is no unique way to see a set as a tuple, but one tuple can be considered as only one set. $\endgroup$ – TheSilverDoe Sep 3 at 10:52
  • $\begingroup$ You can use a multiset, i.e. a set that allows duplicates. Or, if you want to precisely use a set, you could define a bijection from (element, index) pairs which correspond to the ordered elements of the tuple, to some distinct elements that you can put into a set. (For example there is a bijection between natural numbers and pairs of natural numbers.) $\endgroup$ – Vepir Sep 5 at 23:31
1
$\begingroup$

I don't think there's a common notation. And the best way to talk about this depends on how formal your discussion is (and how your tuples are defined).

For most purposes, something like the following would be just fine:

Let $S(T)$ denote the set of values in an ordered tuple $T$. For example, $S((3,5,3))=\{3,5\}$.

But in a more formal setting (a textbook on foundations?) maybe you would say something more like:

Recall that finite tuples of integers such as $(3,5,3)$ can be defined as functions from a finite ordinal to $\mathbb Z$. This allows us to refer to the image set of a tuple: e.g. $\mathrm{Im}(3,5,3)=\{3,5\}$.

| cite | improve this answer | |
$\endgroup$
0
$\begingroup$

Converting a set to a tuple is indeed not really defined since sets are unordered and tuples are ordered.

One specific way I saw in programming is to use binary notation. As an example, if $T=(0,1,1,0,0,1)$, $S$ would be $\{1,2,5\}$

| cite | improve this answer | |
$\endgroup$
  • 1
    $\begingroup$ Sorry if I'm being a bit slow, but could you explain how $(0, 1, 1, 0, 0, 1)$ goes to $\{1, 2, 5\}$? Also, is there a specific function/notation for this? $\endgroup$ – xing Sep 3 at 11:05
  • 1
    $\begingroup$ @xing You have $1$ if the element is present and $0$ if the element is absent. So for the positions $(0,1,2,3,4,5)$, only element $1,2,5$ is present. $\endgroup$ – NimaJan Sep 3 at 12:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.