# An example in the manual about conditions within comprehensions would be great

**URL:** <https://discourse.julialang.org/t/an-example-in-the-manual-about-conditions-within-comprehensions-would-be-great/82343>\
**Category:** Internals & Design\
**Tags:** documentation\
**Created:** [June 6, 2022, 7:49pm UTC](https://discourse.julialang.org/t/an-example-in-the-manual-about-conditions-within-comprehensions-would-be-great/82343 "2022-06-06T19:49:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![skraemer](https://avatars.discourse-cdn.com/v4/letter/s/4bbf92/32.png) [@skraemer](https://discourse.julialang.org/u/skraemer)\
**Post date:** [June 6, 2022, 7:49pm UTC](https://discourse.julialang.org/t/an-example-in-the-manual-about-conditions-within-comprehensions-would-be-great/82343/1 "2022-06-06T19:49:48Z")

</div>

I am not sure if this is the right place to mention this and if it works this way, but I am going to give it a try. I earlier read a post asking for improvements on the manual, and in that spirit this is meant with best intentions to make life easier for others.

In the manual section [Comprehensions](https://docs.julialang.org/en/v1/manual/arrays/#man-comprehensions), it would be really nice to mention the possibility to use conditional such as in:

```julia
julia> [x^2 for x in 1:4 if iseven(x)]
[4,16]

```

This functionality is simple enough that it basically does not require any more explanation and it should not confuse anyone, but at least I did not anticipate this exact way to do so or even its existence without reading about it.

In particular, it is nice to know that this works with `tuple(...)` as well, which is something one might expect upon reading the example above.

---

<div class="post-metadata">

**Author:** ![oheil](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oheil/32/220745_2.png) [@oheil](https://discourse.julialang.org/u/oheil)\
**Post date:** [June 6, 2022, 7:55pm UTC](https://discourse.julialang.org/t/an-example-in-the-manual-about-conditions-within-comprehensions-would-be-great/82343/2 "2022-06-06T19:55:09Z")

</div>

It’s actually there:

> Generated values can be filtered using the `if` keyword:
> 
> ```julia
> julia> [(i,j) for i=1:3 for j=1:i if i+j == 4]
> 2-element Vector{Tuple{Int64, Int64}}:
> (2, 2)
> (3, 1)
> 
> ```

Or, on the top of each page there is a link “Edit on GitHub”. Just try it it’s easy enough.

---

<div class="post-metadata">

**Author:** ![skraemer](https://avatars.discourse-cdn.com/v4/letter/s/4bbf92/32.png) [@skraemer](https://discourse.julialang.org/u/skraemer)\
**Post date:** [June 6, 2022, 8:12pm UTC](https://discourse.julialang.org/t/an-example-in-the-manual-about-conditions-within-comprehensions-would-be-great/82343/3 "2022-06-06T20:12:01Z")

</div>

Oh, I did not see it down there, though I have to say that I would personally prefer it to come up much earlier.

I honestly assumed the “Edit on GitHub” option would just demand of me to have some specific rights. Thanks for mentioning it, maybe I will give it a try with what I mentioned.

So I guess when the section is edited, then someone may review it and possibly approve to merge it into existence in the actual manual?

---

<div class="post-metadata">

**Author:** ![ericphanson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ericphanson/32/215186_2.png) [@ericphanson](https://discourse.julialang.org/u/ericphanson)\
**Post date:** [June 6, 2022, 8:48pm UTC](https://discourse.julialang.org/t/an-example-in-the-manual-about-conditions-within-comprehensions-would-be-great/82343/4 "2022-06-06T20:48:25Z")

</div>

> [@skraemer](#):
>
> So I guess when the section is edited, then someone may review it and possibly approve to merge it into existence in the actual manual?

Yep! There’s a video describing this here:

[![](https://global.discourse-cdn.com/julialang/original/3X/7/8/78788c381cf1489a79ed388897b5896efbae46b4.jpeg "Making Julia documentation better") ](https://www.youtube.com/watch?v=ZpH1ry8qqfw)

(I think that is talking about a package but it’s actually very similar for Julia itself).

---

<div class="post-metadata">

**Author:** ![Sukera](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@Sukera](https://discourse.julialang.org/u/Sukera)\
**Post date:** [June 6, 2022, 8:48pm UTC](https://discourse.julialang.org/t/an-example-in-the-manual-about-conditions-within-comprehensions-would-be-great/82343/5 "2022-06-06T20:48:46Z")

</div>

> [@skraemer](#):
>
> So I guess when the section is edited, then someone may review it and possibly approve to merge it into existence in the actual manual?

Yes - by clicking that button, editing & saving, a new PR is created, which is then reviewed by maintainers and (if good to go) merged into the main repo. When the docs are then built for the next version, they’ll be updated with your change.
