Looking for julia-lang Keywords? Try Ask4Keywords

Julia Language Using REPL Modes


Example

There are three built-in REPL modes in Julia: the Julia mode, the help mode, and the shell mode.

The Help Mode

The Julia REPL comes with a built-in help system. Press ? at the julia> prompt to access the help?> prompt.

At the help prompt, type the name of some function or type to get help for:

help?> abs; search: abs abs2 abspath abstract AbstractRNG AbstractFloat AbstractArray; abs(x); The absolute value of x.; When abs is applied to signed integers, overflow may occur, resulting in the return of a negative value. This overflow occurs only when abs is applied to the minimum representable value of a signed integer. That is, when x == typemin(typeof(x)), abs(x) == x < 0, not -x as might be expected.

Even if you do not spell the function correctly, Julia can suggest some functions that are possibly what you meant:

help?> printline
search:

Couldn't find printline
Perhaps you meant println, pipeline, @inline or print
  No documentation found.

  Binding printline does not exist.

This documentation works for other modules too, as long as they use the Julia documentation system.

julia> using Currencies

help?> @usingcurrencies
  Export each given currency symbol into the current namespace. The individual unit
  exported will be a full unit of the currency specified, not the smallest possible
  unit. For instance, @usingcurrencies EUR will export EUR, a currency unit worth
  1€, not a currency unit worth 0.01€.

  @usingcurrencies EUR, GBP, AUD
  7AUD  # 7.00 AUD

  There is no sane unit for certain currencies like XAU or XAG, so this macro does
  not work for those. Instead, define them manually:

  const XAU = Monetary(:XAU; precision=4)

The Shell Mode

See Using Shell from inside the REPL for more details about how to use Julia's shell mode, which is accessible by hitting ; at the prompt. This shell mode supports interpolating data from the Julia REPL session, which makes it easy to call Julia functions and make their results into shell commands:

shell> ls $(Pkg.dir("JSON")); appveyor.yml  bench  data  LICENSE.md  nohup.out  README.md  REQUIRE  src  test