Reputation: 87
I'm new to Julia lang, and am seeing a lot of julia>
in code examples in numerous documentation.
At first, I thought it was just a REPL code example, but I see them in code examples that look like scripts, so I'm confused.
example from MJLFlux.jl repository:
using MLJ
import RDatasets
iris = RDatasets.dataset("datasets", "iris");
y, X = unpack(iris, ==(:Species), colname -> true, rng=123);
@load NeuralNetworkClassifier
julia> clf = NeuralNetworkClassifier()
NeuralNetworkClassifier(
builder = Short(
n_hidden = 0,
dropout = 0.5,
σ = NNlib.σ),
finaliser = NNlib.softmax,
optimiser = ADAM(0.001, (0.9, 0.999), IdDict{Any,Any}()),
loss = Flux.crossentropy,
epochs = 10,
batch_size = 1,
lambda = 0.0,
alpha = 0.0,
optimiser_changes_trigger_retraining = false) @ 1…60
Upvotes: 3
Views: 173
Reputation: 1474
julia>
is just the REPL prompt as you said.
One reason to include it in examples is so that the output of the command is shown immediately below the command itself. I think that is the reason for the inconsistency in your example code. The author probably omitted the prompt and output on the first few lines for brevity, but did want to show output from the final line.
Another reason may be to distinguish code which the author has stored in a file from code which is being run on the fly in the REPL. Code which sets up a problem environment is likely run once from the file, whereas code that calls the established functions may be tweaked and executed multiple times from the REPL.
There are no strict rules about this, and you may largely ignore it except to note that the text beneath the prompt is probably output rather than executed code. (Note that it is possible to have multiple input and output lines for one REPL prompt though.)
julia> for i in 1:5
println(i)
end
1
2
3
4
5
Upvotes: 2