# A list from each element of another?

Sorry to edit this so much at this late stage, but the question and answers are confused so much by my incorrect use of terminology and the such, I feel that I should clear this up.

Where $a$ and $b$ are lists.

$$a = \{\mathbf{true, false, true, false, false}\}$$ $$b = f(a) = \{0.8, 0, 0.8, 0, 0\}$$

In this case each $\bf true$ in $a$ has become a $0.8$ in $b$, as with $\bf false$ and $0$.

What is $f$?

-
What do you mean by creating? I suppose you could write $b=f[a]$ where $f(true)=0.8,f(false)=0$. –  tomasz Aug 21 '12 at 14:40
What's wrong with $b = \{ 0.8, 0.8, 0\}$? $[]$ represent image. See e.g. math.stackexchange.com/questions/109942/…. –  tomasz Aug 21 '12 at 14:51
Then you should edit your question to make it clear what you want exactly. If it's image, then my comment already answers your question (and I will post it as an answer so that you can accept it). –  tomasz Aug 21 '12 at 15:00

First, note that you are working with multisets rather than sets, since you are allowing repeated elements.

What you have in the example is a function $f: a \rightarrow b$ defined by $$f(x) = \begin{cases} 0.8 & \text{if } x = \text{true}\\ 0 & \text{if } x = \text{false}. \end{cases}$$

You can replace the domain $a$ with any multiset of $0.8$'s and $0$'s. If you want to introduce new elements, you will need to specify how $f$ acts on them.

-

First observe that sets ignore repetitions. Namely, $\{x,x,y\}=\{x,y\}$.

Now you have some $f\colon a\to b$, and you want to say that $f(x)=0.8$, then you can write $f^{-1}(0.8)=x$, or if you prefer $x\in f^{-1}[0.8]$ to suggest that $f(x)=0.8$ but possibly other elements are mapped to $0.8$ as well.

In the same manner, $y\in f^{-1}[0]$ is to say that $f(y)=0$.

To put this into your particular example, $\text{true}=f^{-1}(0.8),\text{false}=f^{-1}(0)$.

-
@alan2here: If those are lists, then the function from the underlying set can be extended to the lists in the obvious way. –  Asaf Karagila Aug 21 '12 at 15:10
@alan2here: I'm not sure what that means. However if you wish that all the elements which have the value $0.8$ in the first list will correspond to elements with value $\text{true}$ in the second list, then setting $f(0.8)=\text{true}$ is fine. –  Asaf Karagila Aug 21 '12 at 15:14