Question : julia lambda functions
Answered by : pouyan
# method 1
x -> x^2 + 2x - 1
# method 2
function (x) x^2 + 2x - 1
end
# example 1:
julia> map(x -> x^2 + 2x - 1, [1, 3, -1])
3-element Vector{Int64}: 2 14 -2
# example 2:
julia> f = x -> x^2 + 2x - 1; f(3)
14
Source : https://docs.julialang.org/en/v1/manual/functions/#man-anonymous-functions | Last Update : Sat, 04 Jun 22