Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running Julia .jl files

I'm new to julia and just finished my first program. I wrote the code in julia-studio and have been testing it within that program. It gives me all of the correct output, but the shell separates the output as if it is two different executions.

I'm wondering if it's a problem with my compiler, so I thought I would try compiling it in the default julia shell found at julialang.org.

However, I cannot understand and/or figure out how to run it there. My current program reads input from another file in the same directory and outputs the results.

Can anyone explain how to run the program. This http://julia.readthedocs.org/en/latest/manual/getting-started/ isn't making sense to me.

Example output:

 julia> program  #  #  #  #    julia>   #  #  #  #  # 

The # represents integer numbers. Ideally the output should not be seperated by "julia>"

like image 314
user1748681 Avatar asked Mar 07 '14 02:03

user1748681


People also ask

How do I run a Julia code from a file?

You can run a Julia file (via Ctrl+F5, which will run whatever Julia file you have open and active), execute Julia commands via the REPL, or even execute a specific block of code from a file you have open.

How do I open a JL file in Julia?

jl , write include("file. jl") . To run code in a file non-interactively, you can give it as the first argument to the julia command: $ julia script.


2 Answers

If you want to run the julia script from a command line then just do

/path/to/julia script-name.jl 

In the shell of your choice.

If you want to run it from the julia repl then you want something like so:

julia> include("path/to/script-name.jl") 

As to why your output is split like that I think we would need to see your code.

like image 90
Jeremy Wall Avatar answered Oct 02 '22 15:10

Jeremy Wall


You can chmod your script and put the path to the julia binary at the to line.

Consider the following simple script hello.jl

#!/usr/bin/julia println("Hello world") 

change permission on the script using

chmod a+x hello.jl 

Run the script using ./hello.jl

like image 30
Fredrik Bagge Avatar answered Oct 02 '22 16:10

Fredrik Bagge