Arrow operator ->

Hello,

I was reading a code and I came across the following:

r(x, δ, b) = [ δ[i] - norm(x - b[:,i]) for i in 1:length(δ) ]
J(x) = ForwardDiff.jacobian(x->r(x, δ, b), x)
xs, err = gauss_newton(x->r(x, δ, b), J, x0)

Could you please explain what the → indicates and provide any doc I could read to understand? I am quite new to this. Thanks for the help!

Thank you

It creates an anonymous function.

6 Likes

Thank you!

More generally if you need to know what syntax does the REPL help mode can be a good starting (and maybe end!) point:

help?> ->
search: ->

  x -> y

  Create an anonymous function mapping argument(s) x to the function body y.

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

  julia> f(2)
  7
4 Likes

This and other symbols are defined here in the documentation.

1 Like

Thanks a lot!