# Broadcasting and piping

**URL:** <https://discourse.julialang.org/t/broadcasting-and-piping/89542>\
**Category:** General Usage\
**Tags:** broadcast, chain, pipe, lazy\
**Created:** [October 31, 2022, 5:45am UTC](https://discourse.julialang.org/t/broadcasting-and-piping/89542 "2022-10-31T05:45:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lincoln\_Hannah](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lincoln_hannah/32/19198_2.png) [@Lincoln\_Hannah](https://discourse.julialang.org/u/Lincoln_Hannah)\
**Post date:** [October 31, 2022, 5:45am UTC](https://discourse.julialang.org/t/broadcasting-and-piping/89542/1 "2022-10-31T05:45:29Z")

</div>

The basic pipe operator allows for broacasting e.g. `1:5 .|> exp`

As far as I know `@chain` and Lazy `@>` don’t support this.  
You can get around this by defining. `⬅map(a,b) = map(b,a)`  
and writing

```julia
@> 1:5 ⬅map(exp)

```

and

```julia
@chain 1:5 begin
    ⬅map(exp)
end

```

Is there a briefer way to do this? maybe through a macro or something?  
be great if you could just writ.

```julia
@> 1:5 exp.

@chain 1:5 begin
         exp.
end

```

---

<div class="post-metadata">

**Author:** ![aplavin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aplavin/32/222056_2.png) [@aplavin](https://discourse.julialang.org/u/aplavin)\
**Post date:** [October 31, 2022, 6:12am UTC](https://discourse.julialang.org/t/broadcasting-and-piping/89542/2 "2022-10-31T06:12:45Z")

</div>

With `DataPipes`:

```julia
using DataPipes

@p 1:5 |> map(exp)
# and even further:
@p 1:5 |> map(exp(_) + 1)

```

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [October 31, 2022, 8:04am UTC](https://discourse.julialang.org/t/broadcasting-and-piping/89542/3 "2022-10-31T08:04:40Z")

</div>

With `Chain` this works:

```julia
@chain 1:5 exp.()

```

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [October 31, 2022, 10:38am UTC](https://discourse.julialang.org/t/broadcasting-and-piping/89542/4 "2022-10-31T10:38:06Z")

</div>

Chain also has `@. exp` although I sometimes wondered if it was good to add it 😉

You can’t really go shorter than `@. exp` or `exp.()` because `exp.` and all variants of it are not valid syntax. At least to my knowledge there’s no way to go shorter here, that’s one slight advantage of `.|>`.

---

<div class="post-metadata">

**Author:** ![Lincoln\_Hannah](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lincoln_hannah/32/19198_2.png) [@Lincoln\_Hannah](https://discourse.julialang.org/u/Lincoln_Hannah)\
**Post date:** [October 31, 2022, 11:22pm UTC](https://discourse.julialang.org/t/broadcasting-and-piping/89542/5 "2022-10-31T23:22:25Z")

</div>

Thanks everyone.  
Some really useful tips
