I’m baffled by this error. Here is the relevant code fragment:
function f1(p)
total = 0.
for i in 1:length(p)-2
q = p[i]
a = p[i+1]
b = p[i+2]
dx = b.x - a.x
dy = b.y - a.y
total += abs(q.x * dy - q.y * dx + b.x * a.y - b.y * a.x);
end
return total
end
println(f1(pointsxy))
@benchmark f1($pointsxy)
and the REPL says:
156.06603667791933
ERROR: LoadError: UndefVarError: f1 not defined
Stacktrace:
[1] ##core#261() at /home/paul/.julia/packages/BenchmarkTools/eCEpo/src/execution.jl:371
[2] ##sample#262(::BenchmarkTools.Parameters) at /home/paul/.julia/packages/BenchmarkTools/eCEpo/src/execution.jl:377
[3] _run(::BenchmarkTools.Benchmark{Symbol("##benchmark#260")}, ::BenchmarkTools.Parameters; verbose::Bool, pad::String, kwargs::Base.Iterators.Pairs{Symbol,Integer,NTuple{4,Symbol},NamedTuple{(:samples, :evals, :gctrial, :gcsample),Tuple{Int64,Int64,Bool,Bool}}}) at /home/paul/.julia/packages/BenchmarkTools/eCEpo/src/execution.jl:405
[4] (::Base.var"#inner#2"{Base.Iterators.Pairs{Symbol,Integer,NTuple{5,Symbol},NamedTuple{(:verbose, :samples, :evals, :gctrial, :gcsample),Tuple{Bool,Int64,Int64,Bool,Bool}}},typeof(BenchmarkTools._run),Tuple{BenchmarkTools.Benchmark{Symbol("##benchmark#260")},BenchmarkTools.Parameters}})() at ./essentials.jl:715
[5] #invokelatest#1 at ./essentials.jl:716 [inlined]
[6] #run_result#37 at /home/paul/.julia/packages/BenchmarkTools/eCEpo/src/execution.jl:32 [inlined]
[7] run(::BenchmarkTools.Benchmark{Symbol("##benchmark#260")}, ::BenchmarkTools.Parameters; progressid::Nothing, nleaves::Float64, ndone::Float64, kwargs::Base.Iterators.Pairs{Symbol,Integer,NTuple{5,Symbol},NamedTuple{(:verbose, :samples, :evals, :gctrial, :gcsample),Tuple{Bool,Int64,Int64,Bool,Bool}}}) at /home/paul/.julia/packages/BenchmarkTools/eCEpo/src/execution.jl:94
[8] #warmup#45 at /home/paul/.julia/packages/BenchmarkTools/eCEpo/src/execution.jl:141 [inlined]
[9] warmup(::BenchmarkTools.Benchmark{Symbol("##benchmark#260")}) at /home/paul/.julia/packages/BenchmarkTools/eCEpo/src/execution.jl:141
[10] top-level scope at /home/paul/.julia/packages/BenchmarkTools/eCEpo/src/execution.jl:287
[11] top-level scope at /home/paul/st/julia/bench6.jl:35
[12] include_string(::Module, ::String, ::String) at ./loading.jl:1080
in expression starting at /home/paul/st/julia/bench6.jl:4
f1
is defined and produces the result shown in the first line. What is happening here?