JM

Code Blocks

We can render code using backticks.

julia
x = 5
print(x)
Output
5

But what if we want to render code?

julia
print("2+2=", 2+2)
julia
function montecarlo(n)
    x = zeros(Float64, n)
    s = 0.0
    for i in 2:n
        s += rand() * 2 - 1 
        x[i] = s
    end

    return x
end

Another code block:

julia
@show sum(montecarlo(10))
Output
sum(montecarlo(10)) = -1.4487235170751755

Testing figure compilation below with the ref Figure 1.

Figure 1: A screenshot of starting a Julia REPL within Visual Studio Code. This is done by using the command palette, accessible using Ctrl+Shift+P.