# Including a function/file in Julia

Hello,
I know this issue is mentioned a few times here but it is still not clear for me how to fix it.

I am trying to define a function then call it in a different Julia code. For instance, I wrote a code for Euler method as follows

function EulerFun1(f::Function, α::Real, a::Real, b::Real, N::Int64)

n1 = N + 1
u = zeros(n1)
t = zeros(n1)
h = (b - a) / N
u[1] = α
t[1] = a

for i in 2:n1
u[i] = u[i-1] + h * f(t[i-1], u[i-1])
t[i] = a + (i - 1) * h
end

return  t, u
end


and I named the file as EulerFun1.jl. When I call the function in a different file like:

include("EulerFun1.jl")


I got this error

LoadError: syntax: { } vector syntax is discontinued around C:\Users\rm18124\EulerFun1.jl:1
in expression starting at C:\Users\rm18124\EulerFun1.jl:1

Stacktrace:
[1] top-level scope
@ C:\Users\rm18124\EulerFun1.jl:1
[2] include(fname::String)
@ Base.MainInclude .\client.jl:451
[3] top-level scope
@ In[61]:1
[4] eval
@ .\boot.jl:373 [inlined]
[5] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)


Any idea how to handle with this situation?

Thanks,

You’ve got something strange in this file: C:\Users\rm18124\EulerFun1.jl
The error has to do with curly brackets {}, which don’t appear in the function you posted, but do appear on line 1 of that file.

3 Likes

It could also be a corrupt Julia installation, does Julia work correctly otherwise? Can you delete all the contents of EulerFun1.jl and include the empty file without errors?

You also have a Unicode character in the first line, maybe it is the encoding of the file that is different in Julia and in your editor.

as you are on Windows, one should ask what text editor you are using?

As you have UTF-8 in there, perhaps it has added a UTF-BOM marker. Try a version of the file with just ASCII