Starting with Julia REPL
We have already learned how to start the Julia REPL and evaluate basic statements in it.
There are various options provided by Julia for running the program. We can directly run statements without even opening the REPL:
$ julia -e 'println("Hello World")' Hello World
We can even run a loop without starting the REPL:
$ julia -e 'for i=1:5; println("Hello World"); end' Hello World Hello World …
It is also possible to pass arguments:
$ julia -e 'for i in ARGS; println(i); end' k2so r2d2 c3po r4 bb8 k2so r2d2 c3po r4 bb8
ARGS is used to take command-line arguments to the script.
We can find the different options that Julia supports using the --help
option:
$ julia --help julia [switches] -- [programfile] [args...] -v, --version Display version information -h, --help Print this message -H, --home <dir> Set location of `julia` executable -e, --eval <expr> Evaluate <expr> -E, --print <expr> Evaluate and...