Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access command line arguments in Julia

Tags:

julia

When I type in

$ julia myprog.jl foo bar baz 

Where in my code can I go to access the strings "foo", "bar", "baz" ?

I'm looking for the Python equivalent of sys.argv

like image 234
MRocklin Avatar asked Jan 11 '14 00:01

MRocklin


People also ask

How do I open julia command line?

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. To learn more about these options, head to Julia in VS Code - Running Code.

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.

How do I get out of julia command line?

To exit the interactive session, type ^D – the control key together with the d key on a blank line – or type exit() followed by the return or enter key.

What is julia command?

Julia is a programming language that is freely available. Launch Binder. We can use Julia without installation by clicking the "launch Binder" badge. The notebook CalculusWithJulia. ipynb is a blank notebook except for the command to load the CalculusWithJulia package.


1 Answers

Ah, more web-searching led to the right answer. The keyword ARGS::Array{ASCIIString} holds command line arguments

Here is a simple example

# cli.jl  print(map(x->string(x, x), ARGS))  # Concatenate each arg onto itself and print 

Lets test it at the command line:

$ julia cli.jl a b c aa bb cc 
like image 151
MRocklin Avatar answered Sep 21 '22 18:09

MRocklin