Tuesday, 12 January 2016

Julia: Execute code in a file

You can evaluate contents of a source file in two ways.
a.   Using interactive session
b.   Using julia command

For example, helloworld.jl contains following data.


helloworld.jl
println("Hello world")
println("Welcome Julia")

Using interactive session
‘include’ command is used to evaluate the statements in given Julia source file.

julia> include("/Users/harikrishna_gurram/helloworld.jl")
Hello world
Welcome Julia


Using Julia command
‘julia fileName’ is used to execute all the statements in a file.

$ julia helloworld.jl 
Hello world
Welcome Julia



Previous                                                 Next                                                 Home

No comments:

Post a Comment