# Filter Dict()

**URL:** <https://discourse.julialang.org/t/filter-dict/22882>\
**Category:** General Usage\
**Tags:** dictionary, functions\
**Created:** [April 7, 2019, 5:08pm UTC](https://discourse.julialang.org/t/filter-dict/22882 "2019-04-07T17:08:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![yan25y](https://avatars.discourse-cdn.com/v4/letter/y/94ad74/32.png) [@yan25y](https://discourse.julialang.org/u/yan25y)\
**Post date:** [April 7, 2019, 5:08pm UTC](https://discourse.julialang.org/t/filter-dict/22882/1 "2019-04-07T17:08:48Z")

</div>

I have a very basic question. When I was looking up how to filter values in Dict(), I came across this documentation

 ![51%20PM](https://global.discourse-cdn.com/julialang/original/3X/e/1/e15b343ac47bae87b3124f9afeff0fc6cf5375d9.png)  
What does p represent, and what do last(p) and first(p) mean?

---

<div class="post-metadata">

**Author:** ![Christopher\_Fisher](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/christopher_fisher/32/26132_2.png) [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)\
**Post date:** [April 7, 2019, 5:15pm UTC](https://discourse.julialang.org/t/filter-dict/22882/2 "2019-04-07T17:15:13Z")

</div>

p is an argument that is passed to the anonymous function. For example, ` x->x+2` is an anonymous function that adds 2 to the input value, x.

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [April 7, 2019, 5:43pm UTC](https://discourse.julialang.org/t/filter-dict/22882/3 "2019-04-07T17:43:49Z")

</div>

See [the docs on anonymous functions](https://docs.julialang.org/en/v1/manual/functions/#man-anonymous-functions-1).

(Also, please [quote your code](https://discourse.julialang.org/t/psa-how-to-quote-code-with-backticks/7530) instead of screenshots).

---

<div class="post-metadata">

**Author:** ![rocco\_sprmnt21](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rocco_sprmnt21/32/20127_2.png) [@rocco\_sprmnt21](https://discourse.julialang.org/u/rocco_sprmnt21)\
**Post date:** [August 24, 2021, 10:46am UTC](https://discourse.julialang.org/t/filter-dict/22882/4 "2021-08-24T10:46:38Z")

</div>

I try to answer the meaning of the question, I hope I am forgiven for inaccuracies in the language.  
As you can see mydict is a list of ‘key =\> val’ pairs.  
the filter (f, dict) function applies the f function to all elements of the dict list in turn. The generic element p has two components (as we have seen).  
If you want to evaluate the key (the first example) you can get it as firts (p) or as last (p) if you want to evaluate the value which is the second (and also the last) element of the pair (the second example) .
