# Why does f /@ x give x

**URL:** <https://community.wolfram.com/t/why-does-f-x-give-x/21381>\
**Category:** Questions\
**Created:** [January 10, 2023, 12:25pm UTC](https://community.wolfram.com/t/why-does-f-x-give-x/21381 "2023-01-10T12:25:05Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![wnjut](https://avatars.discourse-cdn.com/v4/letter/w/9de0a6/32.png) [@wnjut](https://community.wolfram.com/u/wnjut)\
**Post date:** [January 10, 2023, 12:25pm UTC](https://community.wolfram.com/t/why-does-f-x-give-x/21381/1 "2023-01-10T12:25:05Z")

</div>

Hello,everybody! I begin to learn Mathematica. I know /@ means “apply to each element”. so f/@{x} is {f[x]}. But when I try f /@ x, the result is x.I don’t know why. What is the meaning of f /@ x. Would you be kind enough to give me an explanation?

---

<div class="post-metadata">

**Author:** ![vkryukov](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/vkryukov/32/28647_2.png) [@vkryukov](https://community.wolfram.com/u/vkryukov)\
**Post date:** [January 10, 2023, 1:50pm UTC](https://community.wolfram.com/t/why-does-f-x-give-x/21381/2 "2023-01-10T13:50:38Z")

</div>

It’s a bit of an edge case. `Map[f, expr]` applies `f` to each element of expression at level 1. Note that it works with any expression, not just lists:

```
In[12]:= Map[g, f[1,2,3]]
Out[12]= f[g[1],g[2],g[3]]

```

Since `x` is a symbol, it doesn’t have any parts. Compare to

```
In[13]:= Map[f,g[]]
Out[13]= g[]

```

---

<div class="post-metadata">

**Author:** ![wnjut](https://avatars.discourse-cdn.com/v4/letter/w/9de0a6/32.png) [@wnjut](https://community.wolfram.com/u/wnjut)\
**Post date:** [January 10, 2023, 3:13pm UTC](https://community.wolfram.com/t/why-does-f-x-give-x/21381/3 "2023-01-10T15:13:55Z")

</div>

Thank you very much! Inspired by you, I wrote the following words. Are they right?

For g[], it has no element at level 1. In other words, we can think that the element of g[] at level 1 is “nothing”. When f applies to “nothing”, the result is “nothing”(or just indicated by a backspace). So f/@g[] is g[].

---

<div class="post-metadata">

**Author:** ![bradklee](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/bradklee/32/16606_2.png) [@bradklee](https://community.wolfram.com/u/bradklee)\
**Post date:** [January 10, 2023, 4:02pm UTC](https://community.wolfram.com/t/why-does-f-x-give-x/21381/4 "2023-01-10T16:02:32Z")

</div>

Actually, your wording is still confusing, because:

```
g[Nothing]
Out[] = g[Nothing]

```

I would compare g[Nothing] with List[Nothing] as follows:

```
f /@ g[Nothing]
Out[]= g[f[Nothing]]

f /@ List[Nothing]
Out[]= {}

```

The reason for the difference is that List auto-reduces the Nothing to emptiness. Other than that minor difference, List[] and g[] are made indistinguishable when mapping into.

---

<div class="post-metadata">

**Author:** ![vkryukov](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/vkryukov/32/28647_2.png) [@vkryukov](https://community.wolfram.com/u/vkryukov)\
**Post date:** [January 10, 2023, 4:20pm UTC](https://community.wolfram.com/t/why-does-f-x-give-x/21381/5 "2023-01-10T16:20:56Z")

</div>

Happy to help!

As [@Brad Klee](https://community.wolfram.com/web/bradklee) pointed out, `Nothing` is a pre-defined symbol in Wolfram Language, so your reformulation might still be confusing. I would say something like “the set of elements at level 1 for expression `g[]` is empty, so applying `f` to an empty set yields an empty set.”

---

<div class="post-metadata">

**Author:** ![wnjut](https://avatars.discourse-cdn.com/v4/letter/w/9de0a6/32.png) [@wnjut](https://community.wolfram.com/u/wnjut)\
**Post date:** [January 11, 2023, 2:09am UTC](https://community.wolfram.com/t/why-does-f-x-give-x/21381/6 "2023-01-11T02:09:04Z")

</div>

Thank you very much!

---

<div class="post-metadata">

**Author:** ![wnjut](https://avatars.discourse-cdn.com/v4/letter/w/9de0a6/32.png) [@wnjut](https://community.wolfram.com/u/wnjut)\
**Post date:** [January 11, 2023, 2:13am UTC](https://community.wolfram.com/t/why-does-f-x-give-x/21381/7 "2023-01-11T02:13:00Z")

</div>

Thanks so much!
