# Including a function/file in Julia

**URL:** <https://discourse.julialang.org/t/including-a-function-file-in-julia/82211>\
**Category:** New to Julia\
**Tags:** question, module, function\
**Created:** [June 3, 2022, 7:59pm UTC](https://discourse.julialang.org/t/including-a-function-file-in-julia/82211 "2022-06-03T19:59:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Raed\_Maraabeh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/raed_maraabeh/32/36623_2.png) [@Raed\_Maraabeh](https://discourse.julialang.org/u/Raed_Maraabeh)\
**Post date:** [June 3, 2022, 7:59pm UTC](https://discourse.julialang.org/t/including-a-function-file-in-julia/82211/1 "2022-06-03T19:59:47Z")

</div>

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

```julia
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:

```julia
include("EulerFun1.jl")

```

I got this error

```julia
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)
   @ Base .\loading.jl:1196

```

Any idea how to handle with this situation?

Thanks,

---

<div class="post-metadata">

**Author:** ![tomerarnon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tomerarnon/32/3170_2.png) [@tomerarnon](https://discourse.julialang.org/u/tomerarnon)\
**Post date:** [June 3, 2022, 8:38pm UTC](https://discourse.julialang.org/t/including-a-function-file-in-julia/82211/2 "2022-06-03T20:38:05Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![GHTaarn](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ghtaarn/32/216007_2.png) [@GHTaarn](https://discourse.julialang.org/u/GHTaarn)\
**Post date:** [June 6, 2022, 7:07pm UTC](https://discourse.julialang.org/t/including-a-function-file-in-julia/82211/3 "2022-06-06T19:07:44Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![lawless-m](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lawless-m/32/30869_2.png) [@lawless-m](https://discourse.julialang.org/u/lawless-m)\
**Post date:** [June 6, 2022, 7:33pm UTC](https://discourse.julialang.org/t/including-a-function-file-in-julia/82211/4 "2022-06-06T19:33:52Z")

</div>

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

> **[Byte order mark](https://en.wikipedia.org/wiki/Byte_order_mark)**
>
> The byte order mark (BOM) is a particular usage of the special Unicode character, .mw-parser-output .monospaced{font-family:monospace,monospace}U+FEFF BYTE ORDER MARK, whose appearance as a magic number at the start of a text stream can signal several things to a program reading the text:
> BOM use is optional. Its presence interferes with the use of UTF-8 by software that does not expect non-ASCII bytes at the start of a file but that could otherwise handle the text stream.
> Unicode can be enc...
