# How to use anon. func + how to use web irc?

**URL:** <https://discourse.julialang.org/t/how-to-use-anon-func-how-to-use-web-irc/15551>\
**Category:** New to Julia\
**Created:** [September 27, 2018, 9:42am UTC](https://discourse.julialang.org/t/how-to-use-anon-func-how-to-use-web-irc/15551 "2018-09-27T09:42:53Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![mark](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mark/32/5216_2.png) [@mark](https://discourse.julialang.org/u/mark)\
**Post date:** [September 27, 2018, 9:42am UTC](https://discourse.julialang.org/t/how-to-use-anon-func-how-to-use-web-irc/15551/1 "2018-09-27T09:42:53Z")

</div>

In the manual it has this eg

```julia
julia> function (x)
           x^2 + 2x - 1
       end
#3 (generic function with 1 method)

```

How can I call this function?

PS I tried to ask on IRC by visiting the link on the Julia website [IRC](http://webchat.freenode.net/?channels=julia) but it just gave the message `== Cannot send to nick/channel: #julia`.

---

<div class="post-metadata">

**Author:** ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)\
**Post date:** [September 27, 2018, 9:45am UTC](https://discourse.julialang.org/t/how-to-use-anon-func-how-to-use-web-irc/15551/2 "2018-09-27T09:45:18Z")

</div>

```julia
julia> f = function (x)
               x^2 + 2x - 1
           end
#3 (generic function with 1 method)

julia> f(3)
14

```

---

<div class="post-metadata">

**Author:** ![mark](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mark/32/5216_2.png) [@mark](https://discourse.julialang.org/u/mark)\
**Post date:** [September 27, 2018, 9:52am UTC](https://discourse.julialang.org/t/how-to-use-anon-func-how-to-use-web-irc/15551/3 "2018-09-27T09:52:13Z")

</div>

I undertand that I could assign. But in the manual the anon. function is _not_ assigned, so I really want to know how to call it by the “internal” name “#3”.

---

<div class="post-metadata">

**Author:** ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)\
**Post date:** [September 27, 2018, 10:03am UTC](https://discourse.julialang.org/t/how-to-use-anon-func-how-to-use-web-irc/15551/4 "2018-09-27T10:03:53Z")

</div>

I’m sure it’s possible to do this, but why would you? It’s an _anonymous_ function for a reason…

---

<div class="post-metadata">

**Author:** ![mark](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mark/32/5216_2.png) [@mark](https://discourse.julialang.org/u/mark)\
**Post date:** [September 27, 2018, 10:07am UTC](https://discourse.julialang.org/t/how-to-use-anon-func-how-to-use-web-irc/15551/5 "2018-09-27T10:07:55Z")

</div>

This example is given in the manual which I’m trying to edit but as it stands the example can’t be used because there’s no explanation of how it can be done. So, either the example should be removed from the manual or the manual needs to explain how to use it. That’s why I want to know.

---

<div class="post-metadata">

**Author:** ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)\
**Post date:** [September 27, 2018, 10:08am UTC](https://discourse.julialang.org/t/how-to-use-anon-func-how-to-use-web-irc/15551/6 "2018-09-27T10:08:28Z")

</div>

Can you link to the place in the manual that says this?

**Edit:** I suppose you mean here: [Functions · The Julia Language](https://docs.julialang.org/en/v1/manual/functions/#man-anonymous-functions-1)

---

<div class="post-metadata">

**Author:** ![mark](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mark/32/5216_2.png) [@mark](https://discourse.julialang.org/u/mark)\
**Post date:** [September 27, 2018, 10:10am UTC](https://discourse.julialang.org/t/how-to-use-anon-func-how-to-use-web-irc/15551/7 "2018-09-27T10:10:52Z")

</div>

In this section: [https://docs.julialang.org/en/v1/manual/functions/#man-anonymous-functions-1](https://docs.julialang.org/en/v1/manual/functions/#man-anonymous-functions-1)

Two examples are given, but neither of them can be used as-is. Of course the first one could be passed as an argument to, say, `map`, but can the second also be passed?

**Edit:** Oh, it turns out that you really can do say `map(function (x) x^2, a)`, so you don’t need to be able to access the anon. function’s name for this to make sense. I’ll clarify this in the manual.

---

<div class="post-metadata">

**Author:** ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)\
**Post date:** [September 27, 2018, 10:11am UTC](https://discourse.julialang.org/t/how-to-use-anon-func-how-to-use-web-irc/15551/8 "2018-09-27T10:11:54Z")

</div>

But how is that different from e.g.

```julia
julia> sin(3)
0.1411200080598672

```

– there’s no global that contains that result (apart from `ans`, obviously).
